I’d thought that params and variables must be at the top of a template.. yet i can successfully compile this code:
<xsl:template name="WriteOptions">
<xsl:param name="input"/>
<xsl:choose>
<xsl:when test="true()">
</xsl:when>
<xsl:otherwise>
<xsl:param name="head" select="substring-before($input, ',')"/>
<xsl:variable name="tail" select="substring-after($input, ',')"/>
<option value="{$head}"><xsl:value-of select="$head"/></option>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
So i was wondering what’s the catch
Only an
xsl:paramwithin anxsl:templatemust be a child of thexsl:templateinstruction.There is no such requirement for an
xsl:variable— the W3C XSLT 1.0 and XSLT 2.0 specifications allow them to appear at any depth in the XSLT stylesheet.