我认为params和变量必须位于模板的顶部..但我可以成功编译此代码:
<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>
所以我想知道什么是捕获
答案 0 :(得分:2)
根据the spec,您可以将<xsl:param>
写为<xsl:template>
和<xsl:stylesheet>
(或<xsl:transform>
的子项,这是XSLT中的替代顶级元素)。
如果您的样式表编译,那么您的XSLT处理器就会表现为非标准。
答案 1 :(得分:1)
只有xsl:param
中的xsl:template
必须是xsl:template
指令的子级。
对xsl:variable
没有这样的要求 - W3C XSLT 1.0和XSLT 2.0规范允许它们出现在XSLT样式表的任何深度。