Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有关调用模板的XSLT问题&;与param_Xslt - Fatal编程技术网

有关调用模板的XSLT问题&;与param

有关调用模板的XSLT问题&;与param,xslt,Xslt,我把头撞在墙上,想弄明白为什么这行不通: <xsl:call-template name="test-template"> <xsl:with-param name="item" select="WTF" /> </xsl:call-template> <xsl:template name="test-template"> <xsl:param name="item" /> -~<xsl:value-of

我把头撞在墙上,想弄明白为什么这行不通:

<xsl:call-template name="test-template">
    <xsl:with-param name="item" select="WTF" />
</xsl:call-template>

<xsl:template name="test-template">
    <xsl:param name="item" />
    -~<xsl:value-of select="$item" />~-
</xsl:template>

-~~-

输出是:
-~~-
当我想要的是
-~WTF~-

我已经有一段时间没有接触XSLT了-但我认为您的参数名称应该匹配。意思是:

<xsl:call-template name="test-template">
    <xsl:with-param name="is-item-page" select="WTF" />
</xsl:call-template>

<xsl:template name="test-template">
    <xsl:param name="is-item-page" />
    -~<xsl:value-of select="$item" />~-
</xsl:template>

-~~-

试试看。

我已经有一段时间没有接触XSLT了——但我认为您的参数名称应该匹配。意思是:

<xsl:call-template name="test-template">
    <xsl:with-param name="is-item-page" select="WTF" />
</xsl:call-template>

<xsl:template name="test-template">
    <xsl:param name="is-item-page" />
    -~<xsl:value-of select="$item" />~-
</xsl:template>

-~~-

试试看。

首先,正如RonK所说,您的参数名称应该匹配

此外,如果要传递值“WTF”(而不是XML节点“WTF”),则必须对其单引号:

<xsl:call-template name="test-template">
    <xsl:with-param name="item" select="'WTF'" />
</xsl:call-template>

<xsl:template name="test-template">
    <xsl:param name="item" />
    -~<xsl:value-of select="$item" />~-
</xsl:template>

-~~-

首先,正如RonK所说,您的参数名称应该匹配

此外,如果要传递值“WTF”(而不是XML节点“WTF”),则必须对其单引号:

<xsl:call-template name="test-template">
    <xsl:with-param name="item" select="'WTF'" />
</xsl:call-template>

<xsl:template name="test-template">
    <xsl:param name="item" />
    -~<xsl:value-of select="$item" />~-
</xsl:template>

-~~-