I'm currently experiencing much grief over CDATA nodes not transforming correctly. The exact problem is that the processor outputs adjacent CDATA nodes for no apparent reason. I've looked at the text through a hex editor and there are no strange characters causing this to happen.
The problem I'm having seems to be outlined here: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10726
Here's an example of what's happening:
A document containing this:
<element>
<news>
High Estrogen/Progestin Levels May Reduce Asthma Severity
</news>
</element>
Gets transformed to this:
<element>
<news>
<![CDATA[High Estrogen/Progestin Levels May Redu]]><CDATA[ce Asthma Severity]]>
</news>
</element>
Using a stylesheet which specifies that the news element should be cdata:
<xsl:output method="xml" encoding="ISO-8859-1" cdata-section-elements="headline news" media-type="text/xml" standalone="no" />
- I'm currently using Xalan 2.4.1 (unpatched).
- This is a servlet using Tomcat 4.12
- My web-inf/lib contains (xml related) jaxb-api.jar, jaxb-libs.jar, jaxb-ri.jar, jaxen-full.jar, xalan.jar, xerces.jar and xercesImpl.jar
Here's some sample code on how I'm doing it all:
JAXBSource source = null;
JAXBContext jc = JAXBContext.newInstance("blabla");
ObjectFactory factory = new ObjectFactory();
List objects = null;
Marshaller marshaller = jc.createMarshaller();
....
source = new JAXBSource(jc, dgn);
marshaller.marshal(dgn, System.out);
System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer(new StreamSource("mysheet.xslt"));
t.transform(source, new StreamResult(transformedOut));
The marshal statement sends a string of xml back without any CDATA nodes. I rely on the Transform to do that.
I would like to upgrade to 2.5.1d but can't because I keep getting this error as soon as I replace the jar:
The output format must have a '{http://xml.apache.org/xslt}content-handler' property
So I'm stuck with 2.4.1 unless I resolve this other problem.
Thanks for any input.