xsl-list
[Top] [All Lists]

Re: conditional element counting

2003-08-28 13:12:13
I would like to count the number of nodes that have an element containing
a
specific element value.  Can this be done in XSL?

count(/*/Person[Age = 10])

The above is an XPath expression which, when evaluated returns the wanted
value.

Note, that this XPath expression doesn't rely/know about XSLT -- one could
evaluate it using DOM.


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


"Darren Kuik" <darren(_dot_)kuik(_at_)lpl(_dot_)com> wrote in message
news:OPEOKKGGODFCPNLFHGPBOEKPCFAA(_dot_)darren(_dot_)kuik(_at_)lpl(_dot_)com(_dot_)(_dot_)(_dot_)
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



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