trying to insert CDATA section into a xml

2020-05-06 17:27发布

问题:

Hi I have added the below two xsl text nodes to get CDATA in my output xml

<xsl:text disable-output-escaping="yes">&lt;xsl:text disable-output-escaping="yes"&gt;&lt;![CDATA[&lt;/xsl:text&gt;</xsl:text>
<xsl:text disable-output-escaping="yes">&lt;xsl:text disable-output-escaping="yes"&gt;]]&gt;&lt;/xsl:text&gt;</xsl:text>

In My output i am getting the below

<xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>
<xsl:text disable-output-escaping="yes">]]></xsl:text>

I want my output to be like

<xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
<xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>

I am bit new to xslt/xml so any help will be much appreciated :-)

回答1:

Shouldn't it be

<xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text> <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>

If you want your output like the previous

<xsl:text disable-output-escaping="yes">&lt;xsl:text disable-output-escaping="yes"&gt;&amp;lt;![CDATA[&lt;/xsl:text&gt;</xsl:text>
<xsl:text disable-output-escaping="yes">&lt;xsl:text disable-output-escaping="yes"&gt;]]&amp;gt;&lt;/xsl:text&gt;</xsl:text>