File: Data.xml
<?xml version="1.0"?>
<book>
<title>XSLT Topics</title>
<chapter>
<title>XPath</title>
</chapter>
<chapter>
<title>Stylesheet Basics</title>
</chapter>
<chapter>
<title>Branching and Control Elements</title>
</chapter>
<chapter>
<title>Functions</title>
</chapter>
</book>
File: Transform.xslt
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="book">
<xsl:for-each select="chapter|.//sect1|.//sect2|.//sect3">
<xsl:variable name="value1">
<xsl:number level="any" count="chapter|sect1|sect2|sect3"/>
</xsl:variable>
<xsl:number value="$value1 + 999"
grouping-separator="," grouping-size="3"/>
<xsl:text>. </xsl:text>
<xsl:value-of select="title"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Output:
1,000. XPath
1,001. Stylesheet Basics
1,002. Branching and Control Elements
1,003. Functions
|