在XSL中,不能直接在apply-templates中获取参数,因为apply-templates是用于应用模板规则的,而不是用于传递参数的。如果需要传递参数,可以使用with-param或tunnel参数。
with-param是一种直接传递参数的方式,可以在调用模板时直接传递参数值。例如:
<xsl:call-template name="myTemplate">
<xsl:with-param name="myParam" select="'value'"/>
</xsl:call-template>
tunnel参数则是一种隧道传递参数的方式,可以在多层嵌套的模板中传递参数值。例如:
<xsl:call-template name="myTemplate">
<xsl:with-param name="myParam" select="'value'" tunnel="yes"/>
</xsl:call-template>
使用这两种方式可以在XSL中实现参数传递,而不需要使用apply-templates来获取参数。
领取专属 10元无门槛券
手把手带您无忧上云