[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: count() function

Subject: RE: count() function
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Fri, 2 Apr 2004 11:53:52 +0100
xsl count if
> 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.