xsl-list
[Top] [All Lists]

RE: count() function

2004-04-02 03:53:52

I am using a count function to count th enumber of <title> 
tgas in an xml 
file which contain a certain starting letter.
e.g. $alph = 'A'
<xsl:variable name="countletter" select="count(number of 
titles with a 
starting letter of a)"/>
<xsl:if test="($countletter > 0)">
<p><xsl:value-of select="$alph"/></p>
</xsl:if>

How would i write the test case for the xsl:if?
would u do some sort of string comparison like 
not(starts-with($countletter, 
'0'))??

i can't use keys as the xml  is coming from multiple files. 
cheers james

If all you want to do is check if there is a <title> element with the
first text node that starts with 'a' then you can use:

 <xsl:if test="starts-with(//title, 'a')">
   ...
 </xsl:if>

cheers
andrew


<Prev in Thread] Current Thread [Next in Thread>