RE: [xsl] TOC indents in XHTML?

Subject: RE: [xsl] TOC indents in XHTML?
From: Don Bruey <dbruey@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 27 Nov 2001 10:22:32 -0500
One change I would make to this would be to have this template accept
another param, containing the value you want to use for each single level of
indentation.  Have the template simply output that value each time it's

Then you could put this template in your template library and use it
regardless of the context or the input document or the names of elements.
If you don't think you'll need indentation again, the short 3-line solutions
a few people have responded with would be the way to go.  


-----Original Message-----
From: Don Bruey [mailto:dbruey@xxxxxxxxxxxxxxxxxxxxx]
Sent: Tuesday, November 27, 2001 9:38 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] TOC indents in XHTML?

You can write a named template that accepts as a parameter the value of your
$level variable.  Have it create the output you want for a single
indentation, then call itself recursively for each remaining level.
Probably you can find some similar things if you dig through the FAQ.
Something like this:

<xsl:template name="indent">
	<xsl:param name="level"/>
	<xsl:if test="$level &gt; 0" >
  		<!-- put your output here for one indentation level -->
		<xsl:call-template name="indent">
   			<xsl:with-param name="level" select="$level - 1" />

Written on the fly, might need a little work. Good luck.


-----Original Message-----
From: Gustaf Liljegren [mailto:gustaf.liljegren@xxxxxx]
Sent: Tuesday, November 27, 2001 9:25 AM
To: XSL List
Subject: [xsl] TOC indents in XHTML?

I have made a stylesheet to convert an XML document format to XHTML.
Documents conforming to the DTD is divided into a recursive <part> element.
For each level of depth (nested <part> elements) I want another two spaces
in the TOC, like this:

1 The first chapter
  1.1 Some sub-section of the first chapter
  1.2 Another sub-section
2 Another chapter
  2.1 A sub-section of the second chapter
    2.1.1 A sub-sub-section.
    2.1.2 Another sub-sub-section.

Currently, I have a template for the indents that looks like this:

  <xsl:template name="toc-indent">
    <xsl:variable name="level" select="count(ancestor::part)"/>
      <xsl:when test="$level=0"><xsl:text
      <xsl:when test="$level=1"><xsl:text
      <xsl:when test="$level=2"><xsl:text
      <xsl:when test="$level=3"><xsl:text
      <xsl:when test="$level=4"><xsl:text
      <xsl:when test="$level=5"><xsl:text

It works, but it's not smart and far from beautiful. There is a better way
to do it, isn't it? :-)


 XSL-List info and archive:

 XSL-List info and archive:

 XSL-List info and archive:

Current Thread