Skip to content

Instantly share code, notes, and snippets.

@nils-werner
Created December 5, 2011 14:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nils-werner/1433703 to your computer and use it in GitHub Desktop.
Save nils-werner/1433703 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