[XSL-LIST Mailing List Archive Home]
[Reply To This Message]
Re: count Nodes with attributes until... (XSLT 1.0)
Subject: Re: count Nodes with attributes until... (XSLT 1.0)|
From: George Cristian Bina <george@xxxxxxxxxxxxx>
Date: Wed, 28 Jun 2006 12:34:18 +0300
You can count the number of following siblings that have the count-me
attribute set to yes and remove the nodes to be counted after the first
node that does not have a count-me equals with yes attribute:
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
I have to count a number of nodes. Each node that is to be counted has an
attribute 'count-me="yes"' (this is a example :)). But as soon there is a
node which does'nt have such an attribute, or has a attribute
'count-me="false"' this and all following nodes are not to be counted. The
result value is dependent on the number of the node that is in the focus.
The value wanted is e.g. 2 when processing the first node.
This is how I've tried it so far. The problem here is, that when processing
the first Node I always get the value of 4 (what is quite logical to me).
<xsl:template natch="Node" mode="counting_example">
<xsl:variable name="number" select="following-sibling::*[@count-me =
I also tried:
<xsl:variable name="number" select="following-sibling::*[position()
+1][@count-me = 'yes')]"/>
But that just counts the next node if it has the matching attribute.
Let me show what I actually want at the following tabel (using the XML shown
Is this possible? and how?
With best regards,
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