• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic