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

Re: conditional counting of elements

Subject: Re: conditional counting of elements
From: Michel CASABIANCA <casa@xxxxxx>
Date: 08 Mar 2000 23:07:46 +0100
xml counting the 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


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.