<![CDATA[]]>的使用方法在 XSLT 中? [英] How to use <![CDATA[]]> in XSLT?
本文介绍了<![CDATA[]]>的使用方法在 XSLT 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 XSLT 中使用的变量看起来像:
I have use in XSLT variable look like:
<xsl:variable name="ShortDescription" select="str[@name = 'ShortDescription']"/>
<!--Short Description field-->
<xsl:if test="$ShortDescription !=''">
<shortdescription><![CDATA[ <xsl:value-of select="$ShortDescription" disable-output-escaping="no"/> ]]></shortdescription>
</xsl:if>
但它显示为文本而不是 $ShortDescription
变量的值,输出看起来像:
But its display as a text not a value of $ShortDescription
variable and output look like:
<shortdescription>
<xsl:value-of select="$ShortDescription" disable-output-escaping="no"/>
</shortdescription>
预期输出如下:
<shortdescription>
<![CDATA[Maximum Power: 520 W<br/>+12V Rails: Dual<br/>]]>
</shortdescription>
如何在 XSLT 中使用 ?
How to use <![CDATA[]]>
in XSLT?
推荐答案
XSLT 是 XML,所以当然您可以在 XSLT 代码中使用 CDATA 部分,就像您所做的那样.但是,您似乎希望 XSLT 代码的输出包含 shortdescription
内容的 CDATA 部分,在这种情况下,您需要
XSLT is XML so of course you can use a CDATA section in XSLT code, as you have done. However it rather seems you want the output of the XSLT code to contain a CDATA section for the shortdescription
contents, in that case you need
<xsl:output method="xml" cdata-section-elements="shortdescription"/>
XSLT 将保持不变
<shortdescription><xsl:value-of select="$ShortDescription"/></shortdescription>
这篇关于<![CDATA[]]>的使用方法在 XSLT 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文