Created
March 15, 2011 22:35
-
-
Save greystate/871656 to your computer and use it in GitHub Desktop.
An attempt to explain when "/root" will work inside an Umbraco macro
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
<?xml version="1.0" encoding="utf-8" ?> | |
<xsl:stylesheet | |
version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:umb="urn:umbraco.library" | |
exclude-result-prefixes="umb" | |
> | |
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> | |
<xsl:param name="currentPage" /> | |
<!-- Up here, "/*" refers to the <macro> element --> | |
<xsl:template match="/"> | |
<!-- In here, "/*" still refers to the <macro> element --> | |
<xsl:for-each select="$currentPage/*[@isDoc]"> | |
<!-- In here, "/*" will get you <root> - yay! --> | |
</xsl:for-each> | |
<!-- Oh my, back to <macro> with "/*" here --> | |
<xsl:apply-templates select="$currentPage/bannerProperty" /> | |
</xsl:template> | |
<xsl:template match="bannerProperty"> | |
<!-- Again, we will get <root> from "/*" here --> | |
</xsl:template> | |
</xsl:stylesheet> |
Thanks Pete - I seriously hope we'll get to pay each other those beers queued up :-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That is a perfect example of context in macros, in fact not just macros but XSLT in general. The for-each is a nice little hack to use for switching context although it does feel a little dirty at time the way I use it :)
Add another beer to the list of those I owe you...