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

RE: TOC indents in XHTML?

Subject: RE: TOC indents in XHTML?
From: Don Bruey <dbruey@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 27 Nov 2001 09:37:47 -0500
xhtml nbsp
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" />
		</xsl:call-template>
	</xsl:if>
</xsl:template>

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

Don




-----Original Message-----
From: Gustaf Liljegren [mailto:gustaf.liljegren@xxxxxx]
Sent: Tuesday, November 27, 2001 9:25 AM
To: XSL List
Subject:  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:choose>
      <xsl:when test="$level=0"><xsl:text
disable-output-escaping="yes"></xsl:text></xsl:when>
      <xsl:when test="$level=1"><xsl:text
disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;</xsl:text></xsl:when>
      <xsl:when test="$level=2"><xsl:text
disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:
text></xsl:when>
      <xsl:when test="$level=3"><xsl:text
disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;n
bsp;&amp;nbsp;</xsl:text></xsl:when>
      <xsl:when test="$level=4"><xsl:text
disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;n
bsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text></xsl:when>
      <xsl:when test="$level=5"><xsl:text
disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;n
bsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text></xsl:when>
      <xsl:otherwise><xsl:text
disable-output-escaping="yes">&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;n
bsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</xsl:text></xsl:other
wise>
    </xsl:choose>
  </xsl:template>

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

Gustaf




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.