Params and Variables must be at the top of a template?
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"/><开发者_JS百科;/option>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
So i was wondering what's the catch
Per the spec, you can write <xsl:param>
as a child of <xsl:template>
and <xsl:stylesheet>
(or <xsl:transform>
, which is the alternative top level element in XSLT).
If your stylesheet compiles, then your XSLT processor behaves non-standard.
Only an xsl:param
within an xsl:template
must be a child of the xsl:template
instruction.
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.
精彩评论