I'm trying to do an xml to xml translation. The input xml doc
contains some CDATA elements and I want to preserve the CDATA notation
in my output. I had thought that the xsl:output element would take
care of the CDATA notation in my output doc but it is not doing the
trick.
Here's a simplified example of what I'm trying to pull off. Please
let me know if you have any ideas how to do this.
Thanks,
Brent
Input:
<?xml version="1.0"?>
<Report>
<Author>Kilgore Trout</Author>
<Body><![CDATA[Ugly Text Report
Data Row One abcd
Date Row Two efg
The end.
]]>
</Body>
</Report>
Transformer:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/
Transform">
<xsl:output method="xml" cdata-section-elements="Data"/>
<xsl:template match="/">
<Results>
<Data>
<xsl:copy-of select="Report/Body"/>
</Data>
</Results>
</xsl:template>
</xsl:stylesheet>
Output:
<?xml version='1.0' ?>
<Results><Data>Ugly Text Report
Data Row One abcd
Date Row Two efg
The end.
</Data></Results>
Desired Output:
<?xml version='1.0' ?>
<Results><Data><![CDATA[Ugly Text Report
Data Row One abcd
Date Row Two efg
The end.
]]>
</Data></Results>