number level="any" count="chapter|sect1|sect2|sect3" format="Ww - " ordinal="yes"
File: Data.xml <?xml version="1.0"?> <!-- chapters.xml --> <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="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="book"> <xsl:for-each select=".//sect2"> <xsl:number level="any" count="chapter|sect1|sect2|sect3" format="Ww - " ordinal="yes"/> <xsl:value-of select="title"/> <xsl:text>
</xsl:text> </xsl:for-each> </xsl:template> </xsl:stylesheet>