Created
April 10, 2013 12:58
-
-
Save anonymous/5354372 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<data> | |
<navigation> | |
<section id="1" handle="pages">Pages</section> | |
<entry id="1"> | |
<title mode="formatted" word-count="1">Home</title> | |
<url-handle mode="formatted" handle="home" word-count="1">home</url-handle> | |
</entry> | |
<entry id="2"> | |
<title mode="formatted" word-count="2">Sample Page</title> | |
<url-handle mode="formatted" handle="sample-page" word-count="1">sample-page</url-handle> | |
</entry> | |
<entry id="3"> | |
<title mode="formatted" word-count="2">Sub Page</title> | |
<url-handle mode="formatted" handle="sub-page" word-count="1">sub-page</url-handle> | |
<parent> | |
<item id="2" handle="fundamental-analysis" section-handle="pages" section-name="Pages">Sample Page</item> | |
</parent> | |
</entry> | |
</navigation> | |
</data> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |
<xsl:output method="xml" indent="yes" /> | |
<xsl:template match="*[section/@handle='pages']/entry" mode='link'> | |
<xsl:choose> | |
<xsl:when test="parent/item"> | |
<xsl:apply-templates select='../../navigation/entry[@id=current()/parent/item/@id]' mode='link'/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select='$domain'/><xsl:text>/</xsl:text> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:choose> | |
<xsl:when test='url-handle/@handle = "home"'> | |
<!-- home page do not append a handle --> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="url-handle/@handle"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template match="/" > | |
<xsl:variable name='link-to-subpage'> | |
<xsl:apply-templates select='/data/navigation/entry[@id="3"]' mode='link'/> | |
</xsl:variable> | |
<a href='{$link-to-subpage}'>Link to SubPage</a> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment