my dog learned polymorphism*
The moose likes XML and Related Technologies and the fly likes Xerces converting CRLF to LF in text nodes, how to prevent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Xerces converting CRLF to LF in text nodes, how to prevent" Watch "Xerces converting CRLF to LF in text nodes, how to prevent" New topic
Author

Xerces converting CRLF to LF in text nodes, how to prevent

Jeff Gaer
Ranch Hand

Joined: Jun 04, 2001
Posts: 99
<tt><BR>
I'm working on a XML over http application on websphere/windows 2K. I <BR>
believe the libpath has Xerces 1.4.3. I am having a problem <BR>
preserving CRLF in text nodes. It looks to me as if they are being replaced with LF only when the xml stream is parsed. I can build a
dom using the dom parser from a stream that has a text element containing CRLF, retreive the parent node using getElementsByTagName,concatonate all the textNodes that are children of that node using getNodeValue. The resulting string contains only LF instead of CRLF. Is there a way to prevent this short of wraping the text in CDATA?
Thanks in advance for any help.
Jeff Gaer


Sun Certified Java Programmer Java 2<P>Jeff Gaer
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1167
Please read the XML specification at http://www.w3.org/TR/2000/REC-xml-20001006#sec-white-space
The following sections seem to be relevant to your case -
White Space Handling and End-of-Line Handling.
So, it's obvious that Xerces does exactly what it's supposed to do.
I wonder whether the attribute xml:space when set to preserve, will keep the CRLF characters.
Cheers,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Xerces converting CRLF to LF in text nodes, how to prevent
 
Similar Threads
Why is this happening?
normalize( ) in DOM
Put a node into a new xml document
Empty tags in Java DOM API
Urgent - DOM006 Hierarchy request error