Subject: Re: [xsl] 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.
Michael Kay http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] counting the element numb, Michael Kay | Thread | Re: [xsl] counting the element numb, David Carlisle |
RE: [xsl] problem with unc relative, Michael Kay | Date | Re: [xsl] counting the element numb, David Carlisle |
Month |