count(//countmein)
Regards,
Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay
-----Original Message-----
From: W Charlton [mailto:XSLList(_at_)ymonda(_dot_)net]
Sent: 29 May 2009 16:49
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Count all instances of a named element in a tree
Does anyone know an elegant solution to counting all elements
in an XML fragment where the elements to be counted are
nested in a tree? An example of the XML is below:
<xmltree>
<countmein>Node1</countmein>
<nodes>
<node>
<countmein>Node2</countmein>
<level>1</level>
<nodes>
<node>
<countmein>Node3</countmein>
<level>2</level>
<nodes>
<node>
<countmein>Node4</countmein>
<level>3</level>
<nodes/>
</node>
</nodes>
</node>
<node>
<countmein>Node5</countmein>
<level>2</level>
<nodes/>
</node>
<node>
<countmein>Node6</countmein>
<level>2</level>
<nodes/>
</node>
</nodes>
</node>
<node>
<countmein>Node7</countmein>
<level>1</level>
<nodes>
<node>
<countmein>Node8</countmein>
<level>2</level>
<nodes/>
</node>
</nodes>
</node>
</nodes>
</xmltree>
The count in this case would be 8.
I am using XSLT 1.0
Thanks in advance.
William Charlton
The yMonda team
yMonda Limited
w: www.ymonda.net
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--