我有一个生成纯 HTML 的 XSLT 文件。我需要在 CDATA 块中包装一些元素,因此打算使用 cdata-section-elements。但是,如果我想要包含 CDATA 的元素<p>
在页面上只有一个,我如何让它不把 CDATA 放在所有其他<p>
元素中?
输入数据是这样的:
<item>
...
<g:category>Gifts under &pound;10</g:category>
</item>
我的 XSL 是:
<xsl:element name="a">
<xsl:attribute name="href">productlist.aspx</xsl:attribute>
<xsl:copy-of select="text()" />
</xsl:element>
我希望它呈现如下内容:
Gifts under £10
但我得到的只是:
Gifts under £10