Hello Stack Overflow,
I'm working on an Umbraco XSL Stylesheet and I am pretty stuck.
Basically, I have a parameter that I test and use it's value if it's present, otherwise I use the default parameter $currentPage
.
Here are the parameters
<xsl:param name="source" select="/macro/sourceId" />
<xsl:param name="currentPage" />
Here's the variable
<xsl:variable name="current">
<xsl:choose>
<xsl:when test="$source > 0">
<xsl:copy-of select="umbraco.library:GetXmlNodeById($source)" />
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$currentPage" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
And here's where I use it
<xsl:for-each select="msxml:node-set($source)/ancestor-or-self::* [@isDoc and @level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
... code here ...
</xsl:for-each>
In a nutshell
This works
<xsl:variable name="source" select="$currentPage" />
This doesn't
<xsl:variable name="source">
<xsl:copy-of select="$currentPage" /> <!-- Have tried using <xsl:value-of /> as well -->
</xsl:variable>
So how do you copy a variable without using the select=""
attribute.
UPDATE: I've tried using another approach (see below) but I get a variable out of scope exception.
<xsl:choose>
<xsl:when test="$source > 0">
<xsl:variable name="current" select="umbraco.library:GetXmlNodeById($source)" />
</xsl:when>
<xsl:otherwise>
<xsl:variable name="current" select="$currentPage" />
</xsl:otherwise>
</xsl:choose>