问题描述
<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>
不知何故,我不断收到 XSLT 问题...我要做的就是获取变量text"的值,即我是一个 frigggin RRROVERRR",以出现在 ai am a frigggggin' RRROOOVVVERRRR~~中HappyFriend"模板.
somehow i keep getting XSLT issues...all i am trying to do is to get the value of the variable "text" which is "i am a frigggin RRROVERRR" to appear into a i am a frigggggin' RRROOOVVVERRRR~~ in the "HappyFriend" template.
我做错了什么?
推荐答案
几个问题:
-- 字符串文字 'i am a friggin' RRRRROOOOOOOVVVERRRRR~~'
包含不平衡的单引号.你可能想要
-- The string literal 'i am a friggin' RRRRROOOOOOOVVVERRRRR~~'
contains unbalanced single quotes. You probably want
<xsl:with-param name="text" select='"i am a friggin' RRRRROOOOOOOVVVERRRRR~~"'/>
-- call-template
不能出现在模板定义之外.
-- The call-template
cannot occur outside of a template definition.
-- 引用你应该使用的参数value-of-select
,如
-- To refer to the parameter you should be using value-of-select
, as in
<span> <%="<xsl:value-of select="$text"/>"%> </span>
这篇关于从 xsl:template 传递一个字符串参数并在另一个 xsl 文件中使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!