This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Generating multi-level recursive nested lists??
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] Generating multi-level recursive nested lists??
- From: "Joel P Thornton" <joelt at tlchoices dot com>
- Date: Mon, 9 Apr 2001 16:04:17 -0700
- Reply-To: xsl-list at lists dot mulberrytech dot com
| I have been struggling with this for the last few days, and I
| can't seem to
| get it to work. I contacted some other supposed "XML/XSL
| Experts" and they
| couldn't help me. Any help would be greatly appreciated.
|
| [...]
| Here is my XSL: It messes up on the nesting level of my <LI>s.
| [...]
I think this is what you need (excuse the indentation):
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<HTML>
<BODY>
<H1><xsl:value-of select="toc/title"/></H1>
<ol>
<xsl:apply-templates select="toc/folder"/>
</ol>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="folder">
<li id="foldheader"><xsl:value-of select="foldertitle"/></li>
<ol id="foldinglist">
<xsl:apply-templates />
</ol>
</xsl:template>
<xsl:template match="folder/folder">
<LI id="foldheader"><xsl:value-of select="foldertitle"/></LI>
<ol id="foldinglist">
<xsl:apply-templates />
</ol>
</xsl:template>
<xsl:template match="list">
<xsl:for-each select="file">
<li><xsl:apply-templates /></li>
</xsl:for-each>
</xsl:template>
<xsl:template match="text()"><xsl:value-of />
</xsl:template>
</xsl:stylesheet>
.. I think you were introducing your <ol> tags in the wrong spots for what
your intended output. Also you might want some <xsl:if> statements in the
folder and folder/folder templates to prevent having empty <ol></ol> tags
spewing out if there are no children of a particular folder.
joel
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list