File: Data.xml
<?xml version="1.0"?>
<book>
<title>XSLT Topics</title>
<chapter>
<title>title 1</title>
</chapter>
<chapter>
<title>title 2</title>
</chapter>
<chapter>
<title>title 3</title>
</chapter>
<chapter>
<title>title 4</title>
</chapter>
<chapter>
<title>title 5</title>
</chapter>
<chapter>
<title>title 6</title>
</chapter>
<chapter>
<title>title 7</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:number level="single" count="chapter|sect1|sect2|sect3" format="1.1.1.1. "/>
<xsl:value-of select="title"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Output:
1. title 1
2. title 2
3. title 3
4. title 4
5. title 5
6. title 6
7. title 7
|