给定
一个带有全局变量的XSLT样式表:
<xsl:variable name="lang" select="/response/str[@name='lang']"/>
问题
为什么在 xsl:template
匹配模式中使用谓词中的变量是不正确的,但在 xsl:apply-templates
选择模式中使用是可接受的?
<!-- throws compilation error, at least in libxslt -->
<xsl:template match="list[@name='item_list'][$lang]"/>
<!-- works as expected -->
<xsl:template match="list[@name='item_list'][/response/str[@name='lang']]"/>
<!-- works as expected -->
<xsl:template match="response">
<xsl:apply-templates select="list[@name='item_list'][$lang]">
</xsl:template>
$lang
包含字符串值(或数字),而不是某些节点集吗? - YuS