Xerces converting CRLF to LF in text nodes, how to prevent
Jeff Gaer
Ranch Hand
Joined: Jun 04, 2001
Posts: 99
posted
0
<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: 1123
posted
0
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Xerces converting CRLF to LF in text nodes, how to prevent