<xsl:template match="HtmlCode">
<xsl:copy-of select="child::*|text()"/>
</xsl:template>
<xsl:call-template name="HappyFriend">
<xsl:with-param name="text" select="'i am a friggin' RRRRROOOOOOOVVVERRRRR~~'"/>
</xsl:call-template>
<xsl:template name="HappyFriend">
<xsl:param name="text"/>
<HtmlCode>
<span> <%="text"%> </span>
</HtmlCode>
<xsl:template>
Run Code Online (Sandbox Code Playgroud)
不知何故,我一直在收到XSLT问题......我所要做的就是获取变量"text"的值,这是"我是一个frigggin RRROVERRR",在"HappyFriend"中出现了一个frigggggin'RRROOOVVVERRRR ~~ "模板.
我究竟做错了什么?
几个问题:
- 字符串文字'i am a friggin' RRRRROOOOOOOVVVERRRRR~~'包含不平衡的单引号.你可能想要
<xsl:with-param name="text" select='"i am a friggin' RRRRROOOOOOOVVVERRRRR~~"'/>
Run Code Online (Sandbox Code Playgroud)
- call-template不能在模板定义之外发生.
- 参考您应该使用的参数value-of-select,如
<span> <%="<xsl:value-of select="$text"/>"%> </span>
Run Code Online (Sandbox Code Playgroud)