|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Numbered Lists
How can I generate a numbered list for a table of contents in XSL? I can generate and indent the table of contents, but I can't get the numbering to work. I thought of using the count() function. That works nicely for the chapters in the contents, but fails for the chapter names in the document. (They should match.) I thought of using a variable, but that seems quite messy. Any suggestions? My XML document is like this: <root> <chapter><name>Name of first chapter</name> <section><name>Chapter 1 section 1</name></section> <section><name>Chapter 1 section 2</name></section> <chapter><name>Name of second chapter</name> </root> I want my document to be like this: TABLE OF CONTENTS 1. Name of first chapter 1.1 Chapter 1 section 1 1.2 Chapter 1 section 2 2. Name of second chapter Here's my XSL: <xsl:template match="/"> <ul> <xsl:for-each select="chapter/name"> <li><a> <xsl:attribute name="HREF">#<xsl:value-of select="generate-id()"/></xsl:attribute> <xsl:value-of select="position()"/>. <xsl:value-of select="."/> <ul> <xsl:for-each select="../section/name"> <li><a> <xsl:attribute name="HREF">#<xsl:value-of select="generate-id()"/></xsl:attribute> <xsl:value-of select="."/> </a></li> </xsl:for-each> </ul> </a></li> </xsl:for-each> </ul> </td></tr></table></center> <xsl:apply-templates/> </xsl:template> <xsl:template match="section/name"> <h3><a><xsl:attribute name="NAME"><xsl:value-of select="generate-id()"/></xsl:attribute><xsl:value-of select="position()"/><xsl:value-of select="."/></a></h3><br/> </xsl:template> <xsl:template match="chapter/name"> <h2><a><xsl:attribute name="NAME"><xsl:value-of select="generate-id()"/></xsl:attribute><xsl:value-of select="position()"/><xsl:value-of select="."/></a></h2><br/> </xsl:template> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








