Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Jeff Gaer
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic