我正在使用XSLT转换,需要在CDATA部分放置一些数据,并且该值存在于变量中。
查询:如何访问CDATA中的变量? 下面给出的样本:
<xsl:attribute name ="attributeName">
<![CDATA[
I need to access some variable here like
*<xsl:value-of select ="$AnyVarible"/>*
]]>
</xsl:attribute>
如何在CDATA中使用varibale?
注意:我不能使用 - &gt; <![CDATA[<xsl:value-of select ="$AnyVarible"/>]]>
提前谢谢。
答案 0 :(得分:6)
我得到了解决方案...每个人都支持...
<xsl:text
disable-output-escaping="yes"><![CDATA[</xsl:text>
<xsl:value-of select ="$AnyVarible"/>
<xsl:text
disable-output-escaping="yes">]]></xsl:text>
答案 1 :(得分:3)
CDATA就像任何其他元素内容一样......
但是使用xsl:output
元素,您应该能够使用cdata-section-elements
属性指定要将哪些元素写为CDATA。
修改强>
现在有一个有效的样本,我想你的意思是:
<xsl:attribute name ="attributeName">
<![CDATA[
I need to access some variable here like
*]]><xsl:value-of select ="$AnyVarible"/><![CDATA[*
]]>
</xsl:attribute>
答案 2 :(得分:3)
如果要在输出中包含CDATA节,则应使用xsl:output的cdata-section-elements属性。这是元素名称列表。任何此类元素的文本内容都将包含在CDATA中。
<xsl:output cdata-section-elements ="foo" />
<foo>
<xsl:value-of select="$bar' />
</foo>