Created
April 15, 2011 23:15
-
-
Save greystate/922634 to your computer and use it in GitHub Desktop.
Code listings (legacy XML Schema) for "An intro to using match templates in Umbraco" (Pimp My XSLT article)
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]> | |
| <xsl:stylesheet | |
| version="1.0" | |
| xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
| xmlns:msxml="urn:schemas-microsoft-com:xslt" | |
| xmlns:umbraco.library="urn:umbraco.library" | |
| exclude-result-prefixes="msxml umbraco.library"> | |
| <xsl:output method="xml" omit-xml-declaration="yes"/> | |
| <xsl:param name="currentPage"/> | |
| <xsl:template match="/"> | |
| <!-- The fun starts here --> | |
| <ul> | |
| <xsl:for-each select="$currentPage/node [string(data [@alias = 'umbracoNaviHide]) != '1']"> | |
| <li> | |
| <a href="{umbraco.library:NiceUrl(@id)}"> | |
| <xsl:value-of select="@nodeName"/> | |
| </a> | |
| </li> | |
| </xsl:for-each> | |
| </ul> | |
| </xsl:template> | |
| </xsl:stylesheet> |
This file contains hidden or 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:template match="/"> | |
| <ul> | |
| <xsl:apply-templates select="$currentPage/node [string(data [@alias = 'umbracoNaviHide]) != '1']" /> | |
| </ul> | |
| </xsl:template> | |
| <xsl:template match="node"> | |
| <li> | |
| <a href="{umbraco.library:NiceUrl(@id)}"> | |
| <xsl:value-of select="@nodeName" /> | |
| </a> | |
| </li> | |
| </xsl:template> |
This file contains hidden or 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:template match="/"> | |
| <ul> | |
| <xsl:apply-templates select="$currentPage/node" /> | |
| </ul> | |
| </xsl:template> | |
| <xsl:template match="node"> | |
| <li> | |
| <a href="{umbraco.library:NiceUrl(@id)}"> | |
| <xsl:value-of select="@nodeName" /> | |
| </a> | |
| </li> | |
| </xsl:template> | |
| <xsl:template match="node[data[@alias = 'umbracoNaviHide'] = 1]" /> |
This file contains hidden or 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:template match="/"> | |
| <xsl:apply-templates select="$currentPage" /> | |
| </xsl:template> | |
| <xsl:template match="node[@nodeTypeAlias = 'News'] | node[@nodeTypeAlias = 'Events']"> | |
| <h2> | |
| <xsl:value-of select="@nodeTypeAlias" /> | |
| </h2> | |
| <ul> | |
| <xsl:apply-templates select="node[@nodeTypeAlias = 'NewsItem'] | node[@nodeTypeAlias = 'Event']" /> | |
| </ul> | |
| </xsl:template> | |
| <xsl:template match="node[@nodeTypeAlias = 'NewsItem'] | node[@nodeTypeAlias = 'Event']"> | |
| <li> | |
| <a href="{umbraco.library:NiceUrl(@id)}"> | |
| <xsl:value-of select="@nodeName" /> | |
| </a> | |
| </li> | |
| </xsl:template> | |
| <xsl:template match="node[data[@alias = 'umbracoNaviHide'] = 1]" /> |
This file contains hidden or 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:template match="/"> | |
| <xsl:apply-templates select="$currentPage/ancestor-or-self::node[@nodeTypeAlias = 'News' or @nodeTypeAlias = 'Events']" /> | |
| </xsl:template> |
This file contains hidden or 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:template match="node[@nodeTypeAlias = 'News'] | node[@nodeTypeAlias = 'Events']"> | |
| <h2> | |
| <xsl:value-of select="@nodeTypeAlias" /> | |
| </h2> | |
| <ul id="{translate(@nodeTypeAlias, 'NE', 'ne')}"> | |
| <xsl:apply-templates select="node[@nodeTypeAlias = 'NewsItem'] | node[@nodeTypeAlias = 'Event']" /> | |
| </ul> | |
| </xsl:template> | |
| <xsl:template match="node[@nodeTypeAlias = 'NewsItem'] | node[@nodeTypeAlias = 'Event']"> | |
| <li> | |
| <xsl:if test="@id = $currentPage/@id"><xsl:attribute name="class">selected</xsl:attribute></xsl:if> | |
| <a href="{umbraco.library:NiceUrl(@id)}"> | |
| <xsl:value-of select="@nodeName" /> | |
| </a> | |
| </li> | |
| </xsl:template> |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]> | |
| <xsl:stylesheet version="1.0" | |
| xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
| xmlns:umbraco.library="urn:umbraco.library" | |
| exclude-result-prefixes="umbraco.library"> | |
| <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" /> | |
| <xsl:param name="currentPage" /> | |
| <xsl:template match="/"> | |
| <xsl:apply-templates select="$currentPage/ancestor-or-self::node[@nodeTypeAlias = 'News' or @nodeTypeAlias = 'Events']" /> | |
| </xsl:template> | |
| <xsl:template match="node[@nodeTypeAlias = 'News'] | node[@nodeTypeAlias = 'Events']"> | |
| <h2> | |
| <xsl:value-of select="@nodeTypeAlias" /> | |
| </h2> | |
| <ul id="{translate(@nodeTypeAlias, 'NE', 'ne')}"> | |
| <xsl:apply-templates select="node[@nodeTypeAlias = 'NewsItem'] | node[@nodeTypeAlias = 'Event']" /> | |
| </ul> | |
| </xsl:template> | |
| <xsl:template match="node[@nodeTypeAlias = 'NewsItem'] | node[@nodeTypeAlias = 'Event']"> | |
| <li> | |
| <xsl:if test="@id = $currentPage/@id"><xsl:attribute name="class">selected</xsl:attribute></xsl:if> | |
| <a href="{umbraco.library:NiceUrl(@id)}"> | |
| <xsl:value-of select="@nodeName" /> | |
| </a> | |
| </li> | |
| </xsl:template> | |
| <xsl:template match="node[data[@alias = 'umbracoNaviHide'] = 1]" /> | |
| </xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment