XSLT调用带有XSL模板:在不同的模板,-PARAM(XSLT calling template

2019-10-18 16:36发布

我在我的实时XSLT文件有问题。 在此基础上,我在这里把我的问题。 我有3个XSLT文件如1.xsl2.xslmaster.xsl 。 这master.xsl导入到1.xsl2.xsl

在master.xsl,我使用这下面的代码

<xsl:call-template name="content">
<xsl:with-param name="request" select="$request"/>
<xsl:call-template>

像明智的,在1.xsl

<xsl:template name="content">
<xsl:param name="request" as="node()"/>
....
</xsl:template>

2.xsl

<xsl:template name="content">

....
</xsl:template>

如果,我是执行此2.xsl ,我收到以下错误:

XTSE0680: Parameter request is not declared in the called template

实际上,当我执行只需要请求变量1.xsl 。 另外,我不上的模板声明哑变量2.xsl 。 这样,我在实时许多XSLT文件。 这样,我不能够在许多XSLT文件来声明相同的变量,因为它会更多的时间和它不会是一致的。

谁能给我一个想法克服这个?

Answer 1:

那么对于XSLT 2.0的规则说清楚在http://www.w3.org/TR/xslt20/#err-XTSE0680 :“在XSL的情况:调用模板,它是一个静态误差通过非通道参数名为x的模板没有名为X的模板参数,除非向后兼容的行为是启用的xsl:调用模板的指令“。

因此,用XSLT 2.0,如果你想使用的代码

<xsl:call-template name="content">
<xsl:with-param name="request" select="$request"/>
<xsl:call-template>

那么你需要确保任何所谓的模板content有参数request宣告。

对于规则apply-templates是不同的,我认为这样你可以检查是否你不能简单地写了一个模板match属性,使用apply-templates



文章来源: XSLT calling template with xsl:with-param on different template
标签: xslt