I have an XSLT transformation with several nested <xsl:for-each>
and <xsl:apply-templates>
.
Now i need to number the nodes at the end of this for-each and apply-templates. Everything I tried just numbered the iterations on an level of for-each (e.q. 1,2,3,4,1,2,1,2,3,4 but I need 1,2,3,4,5,6,7,8,9,10)
(I'm pretty inexperienced with XSLT, but attempted to solve this problem with different variants of <xsl:number>
and position()
.)
test.xml
<A>
<B>
<C/>
<C/>
<C/>
<C/>
</B>
<B>
<C/>
<C/>
</B>
</A>
text.xsl:
<xsl:template match="A">
<xsl:for-each select="B">
<xsl:for-each select="C">
<xsl:number/>,
</xsl:for-each>
</xsl:for-each>
</xsl:template>
test.out
1,2,3,4,1,2,
I would like to have
1,2,3,4,5,6
EDIT: This example is to simple, it works with <xsl:number level="any" />
. I first have to make a better example