Skip to content

Instantly share code, notes, and snippets.

@michael-e
Forked from nils-werner/noroot.xsl
Created December 5, 2011 22:58
Show Gist options
  • Save michael-e/1435804 to your computer and use it in GitHub Desktop.
Save michael-e/1435804 to your computer and use it in GitHub Desktop.
<!-- Not displaying $root -->
<xsl:template match="page" mode="url">
<xsl:apply-templates select="parent::page" mode="url"/>
<xsl:value-of select="concat(@handle,'/')"/>
</xsl:template>
<!-- Displaying $root, in one template -->
<xsl:template match="page" mode="url">
<xsl:apply-templates select="parent::page" mode="url"/>
<xsl:if test="not(parent::page)">
<xsl:value-of select="concat($root,'/')"/>
</xsl:if>
<xsl:value-of select="concat(@handle,'/')"/>
</xsl:template>
<!-- Displaying $root without the if -->
<xsl:template match="page" mode="url">
<xsl:value-of select="concat($root,'/',@handle,'/')"/>
</xsl:template>
<xsl:template match="page/page" mode="url">
<xsl:apply-templates select="parent::page" mode="url"/>
<xsl:value-of select="concat(@handle,'/')"/>
</xsl:template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment