This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: TOC indents in XHTML?
- From: Jeff Beadle <Jbeadle at manh dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 27 Nov 2001 09:32:27 -0500
- Subject: RE: [xsl] TOC indents in XHTML?
- Reply-to: xsl-list at lists dot mulberrytech dot com
this may not be much better, but you could either create a template to
generate the desired number of spaces--maybe even a "tab" template?
or you could define an entity like this:
<!DOCTYPE xsl:stylesheet [<!ENTITY tab "     ">]>
-----Original Message-----
From: Gustaf Liljegren [mailto:gustaf.liljegren@xml.se]
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: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">&nbsp;&nbsp;</xsl:text></xsl:when>
<xsl:when test="$level=2"><xsl:text
disable-output-escaping="yes">&nbsp;&nbsp;&nbsp;&nbsp;</xsl:
text></xsl:when>
<xsl:when test="$level=3"><xsl:text
disable-output-escaping="yes">&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;</xsl:text></xsl:when>
<xsl:when test="$level=4"><xsl:text
disable-output-escaping="yes">&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;</xsl:text></xsl:when>
<xsl:when test="$level=5"><xsl:text
disable-output-escaping="yes">&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</xsl:text></xsl:when>
<xsl:otherwise><xsl:text
disable-output-escaping="yes">&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&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