[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Creating a hierarchical table of contents using xsl:n

Subject: Creating a hierarchical table of contents using xsl:number
From: Martin Jackson <martsonjackin@xxxxxxxxx>
Date: Tue, 16 Feb 2010 20:32:35 +0100
 Creating a hierarchical table of contents using  xsl:n
I'm trying to create a table of content that looks like this:

1. Fruit
1.1. Citrus
1.1.1. Orange
1.1.2. Lemon
1.1.3. Lime
1.2. Apple
2. Vegetables
2.1. Tomato
2.2. Carrot

from an xml file with this structure

<level1 title="fruit">
   <level2 title="citrus">
      <level3 title="orange"/>
      <level3 title="lemon"/>
      <level3 title="lime"/>
   <level2 title="apple"/>
<level1 title="vegetables">
   <level2 title="tomato"/>
   <level2 title="carrot"/>

But I can't figure out how to make my xsl transformation write the
numbers for all the levels in the hierarchy. Right now it just outputs
the bottom level, so it looks like this:

1. Fruit
1. Citrus
1. Orange
2. Lemon
3. Lime
2. Apple
2. Vegetables
1 Tomato
2 Carrot

This is what my code looks like:

<xsl:for-each select="level1">
	<xsl:number level="multiple" count="h1" value="position()" format="1.1. "/>
	<xsl:value-of select="@title"/><br />
	<xsl:for-each select="level2">
		<xsl:number level="multiple" count="h1|h2" value="position()" format="1.1. "/>
		<xsl:value-of select="@title"/><br />
		<xsl:for-each select="level3">
			<xsl:number level="multiple" count="h1|h2|h3" value="position()"
format="1.1.  "/>
			<xsl:value-of select="@title"/><br />

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.