number level="any" from="book" count="chapter" format="1."
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=".//sect3"> <xsl:number level="any" from="book" count="chapter" format="1."/> <xsl:number level="any" from="chapter" count="sect1" format="1."/> <xsl:number level="any" from="sect1" count="sect2" format="1."/> <xsl:number level="any" from="sect2" count="sect3" format="1. "/> <xsl:value-of select="title"/> <xsl:text>
</xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet>