Subject: Re: [xsl] sorting into a tree structure From: Martin Honnen <Martin.Honnen@xxxxxx> Date: Tue, 06 Oct 2009 18:53:07 +0200 |
I'd like to limit the number of levels that the tree goes down. What's the best way of achieving this? Is this through count(ancestor::*)?
<xsl:template match="folders"> <ul> <xsl:apply-templates select="key('val', '')"> <xsl:with-param name="level" select="1"/> </xsl:apply-templates> </ul> </xsl:template>
<xsl:template match="Item"> <xsl:param name="level"/> <xsl:choose> <xsl:when test="key('val', @ID) and $level <= $max-level"> <li><xsl:value-of select="@title"/></li> <ul> <xsl:apply-templates select="key('val', @ID)"> <xsl:sort select="@order" data-type="number"/> <xsl:with-param name="level" select="$level + 1"/> </xsl:apply-templates> </ul> </xsl:when> <xsl:otherwise> <li><xsl:value-of select="@title"/></li> </xsl:otherwise> </xsl:choose> </xsl:template>
Martin Honnen http://msmvps.com/blogs/martin_honnen/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] sorting into a tree struc, Manfred Staudinger | Thread | [xsl] key declarations (using a seq, Andy Chambers |
Re: [xsl] sorting into a tree struc, Manfred Staudinger | Date | [xsl] key declarations (using a seq, Andy Chambers |
Month |