Subject: [xsl] Numbered Lists From: "Hewko, Doug" <Doug.Hewko@xxxxxxxxxxxxxxx> Date: Tue, 9 Oct 2001 16:04:07 -0400 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Parsing Input Data for we, cutlass | Thread | Re: [xsl] Numbered Lists, Thomas B. Passin |
Re: [xsl] Re: Overlapping structure, Francois Lachance | Date | Re: [xsl] Re: Overlapping structure, Robin Cover |
Month |