Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<!-- 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
You can’t perform that action at this time.