Hi there,
I want to have an output like:
====== begin intended output ==================== <cdata-node><![CDATA[ <b> <c>test</c> </b> ]]></cdata-node> <cdata-node><![CDATA[normal text]]></cdata-node> ======= end intended output =====================
for this XML document:
======= begin XML input ========================= <?xml version="1.0" encoding="UTF-8"?> <a> <b> <c>test</c> </b> </a> ======== end XML input ==========================
I created the following stylesheet:
======== begin stylesheet ======================= <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" cdata-section-elements="cdata-node"/> <xsl:template match="/"> <cdata-node> <xsl:copy-of select="a" /> </cdata-node> <cdata-node>normal text</cdata-node> </xsl:template> </xsl:stylesheet> ========= end stylesheet ========================
Unfortunately, this is the result:
======== begin output =========================== <?xml version="1.0" encoding="UTF-8"?> <cdata-node><a> <b> <c>test</c> </b> </a></cdata-node><cdata-node><![CDATA[normal text]]></cdata-node> ========= end output ============================
How do I get a <![CDATA[ ]]> section in the first <cdata-node> node? I read CDATA is written for text only. At least, the 'normal text' has been included in CDATA. How do I achieve to convert the result tree into plain text, so it can be surrounded by CDATA brackets?
Any help is appreciated. Thanks,
Johannes