Skip to content

Instantly share code, notes, and snippets.

@nils-werner
Created September 16, 2010 12:12
Show Gist options
  • Save nils-werner/582324 to your computer and use it in GitHub Desktop.
Save nils-werner/582324 to your computer and use it in GitHub Desktop.
<ul>
<xsl:apply-templates select="/data/categories/entry[not(parent)]" />
</ul>
<xsl:template match="categories/entry">
<xsl:param name="path" select="''" />
<li id="{title/@handle}">
<a href="{$root}{$path}{title/@handle}/">
<xsl:value-of select="title" />
</a>
<xsl:if test="/data/categories/entry[parent/item/@handle = current()/title/@handle]">
<ul>
<!-- recursively call all elements with parent-nodes pointing to current node -->
<xsl:apply-templates select="../entry[parent/item/@id = current()/@id]">
<xsl:with-param name="path" select="concat($path,'/',title/@handle)" />
</xsl:apply-templates>
</ul>
</xsl:if>
</li>
</xsl:template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment