[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] conditional element counting


Subject: RE: [xsl] conditional element counting
From: cknell@xxxxxxxxxx
Date: Thu, 28 Aug 2003 15:49:51 -0400

Here's the template:

<xsl:template match="/">
  <xsl:value-of select="count(Rootnode/Person[Age='10'])" />
</xsl:template>
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     "Darren Kuik" <darren.kuik@xxxxxxx>
Sent:     Thu, 28 Aug 2003 14:32:42 -0500
To:       <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
Subject:  [xsl] conditional element counting

I would like to count the number of nodes that have an element containing a
specific element value.  Can this be done in XSL?  I couldn't find this in
the archive so I apologize if this has been posted before?

Suppose I have an XML file that looks like this:

<Rootnode>
  <Person>
    <Name>Joe</Name>
    <Age>10</Age>
  </Person>
  <Person>
    <Name>John</Name>
    <Age>10</Age>
  </Person>
  <Person>
    <Name>Sam</Name>
    <Age>18</Age>
  </Person>

I want to use XSL to count and display the number of Person nodes that have
an Age element with value = 10.  Is this possible?

Thanks,
Darren


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords