开发者

XSLT problem concerning call-template & with-param

I'm banging my head against the wall trying to figure out why this won't work:

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

<x开发者_Python百科sl:template name="test-template">
    <xsl:param name="item" />
    -~<xsl:value-of select="$item" />~-
</xsl:template>

Output is: -~~- when what I want is -~WTF~-


First of all, as RonK said, your parameter names should match.

Also, if you want to pass the value "WTF" (instead of XML node "WTF"), you've to single-quote it:

<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>


I haven't touched XSLT for quite some time - but I think your parameter names should match. Meaning:

<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>

Try it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜