Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Transforming XML/XSLT : CDATA problem

843834Apr 30 2002 — edited Jul 7 2003
Hi!

I have a problem transforming xml with XSLT using the API javax.xml.
The result is correct until I have a CDATA section in my xml document.
The transforming process encodes all the & < > (special characters) it finds in.
This occurs problem for the follow of my treatement because the content of my CDATA is already encoded.

For example, this xml code :

<?xml version='1.0' encoding="ISO-8859-1" ?>
<article>
<article-contenu><![CDATA[Accent : &eacute; Signe : &lt;]]></article-contenu>
</article>

produces in my output :

Accent : &amp;eacute; Signe : &amp;lt;

This is my java code :

TransformerFactory tFactory = TransformerFactory.newInstance();

Source xmlSource = new StreamSource(readerXml);
Source xslSource = new StreamSource( fileXsl );

// Generate the transformer.
Transformer transformer = tFactory.newTransformer(xslSource);
// Perform the transformation, sending the output to the response.
transformer.transform(xmlSource, new javax.xml.transform.stream.StreamResult(sw));

How can I tell the transformer not to do that?

Thanks for your answers!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 4 2003
Added on Apr 30 2002
3 comments
550 views