[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: conditional counting of elements
Hello PAPINENI Sivaprakash <SPapinen@xxxxxxxxxx> writes: > Sample Xml file: > > <?xml version="1.0"?> > <company> > <department id="1"> > <item>book</item> > </department> > <department id="2"> > <item>table</item> > </department> > <department id="3"> > <item>book</item> > </department> > </company> > > I'm trying to count the number of 'departments' that have value 'book' for > 'item' element in the above Xml using XSLT(the latest version of Xalan) and > display it in html. You can use such a stylesheet : <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="/"> <xsl:value-of select="count(//department[item='book'])"/> </xsl:template> </xsl:stylesheet> -- +---------------------------+--------------------------------+ | Michel CASABIANCA | http://www.sdv.fr/pages/casa | | mailto:casa@xxxxxx | Articles sur Java et XML | | Développement Java et XML | Applications et Applets de Jeu | +---------------------------+--------------------------------+ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|