Below I am counting elements using xsl:number
. I would like to count the chapters in order, see below:
XML:
<map>
<part>
<chapter/>
</part>
<chapter/>
<part>
<chapter/>
<chapter/>
</part>
</map>
XSLT:
<xsl:template match="chapter">
<xsl:variable name="chapNum">
<xsl:number count="chapter" format="1"/>
</xsl:variable>
<xsl:v开发者_运维问答alue-of select="$chapNum"/>
</xsl:template>
OUTPUT:
1
1
1
2
Desired OUTPUT:
1
2
3
4
I believe I need to use the from attribute but I am not sure how to implement it.
Thanks for any help in advance!
Use <xsl:number level="any"/>
精彩评论