[XSL-LIST Mailing List Archive Home]
[Reply To This Message]
Re: counting the element number in a recursive tree
Subject: Re: counting the element number in a recursive tree|
From: "Mohsen Saboorian" <mohsens@xxxxxxxxx>
Date: Mon, 26 Jun 2006 15:05:03 +0330
If position() returns even numbers, it's because you are counting text nodes
as well as elements. The answer is to count only the elements, which will
happen if you use <xsl:for-each select="*"> or <xsl:apply-templates
select="*"> rather than using select="node()".
I didn't used select="node()", but just called <xsl:apply-templates
/>, so it would be applied to all descendant recursively I think.
Using <xsl:apply-templates select="*" />, the problem was there, but
<xsl:number level="single" /> was what I wanted.
Dividing position() by 2 is wrong, because the whitespace text nodes won't
always be there.
Alternatively, use xsl:number.
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