I'm doing a xstl transformation with saxon from an XML document.
The doc is not standard-valid XML, and I want to preserve all
Transformer trans = TransformerFactory.newInstance().newTransformer(new StreamSource(new File("foo.xsl"));
trans.transform(new StreamSource(new File("foo.xml"), new StreamResult(new File("output.xml")));
You can't, as the distinction whether a text originated from a cdata section is not available in the datamodel used by xslt. You can however define in your stylesheet that certain result elements are to be wrapped inside cdata. This is done using the
cdata-section-elements attribute of the
xsl:output element in your stylesheet.