Re: XMLOutputter line breaks and TextMode.PRESERVE

Rolf Lear <[email protected]>
Newsgroups gmane.comp.java.jdom.general
Message-ID <[email protected]>
Hi Christian.

Without digging in to the Textmode.PRESERVE thing... your other options 
are CDATA, and also adding the attribute xml:space="preserve" to the 
<data> element.... like:

<data xml:space="preserve">first line\r\nsecond line</data>


Rolf

Christian Migowski wrote:
> Hi,
>
> to my big disappointment I found out that the XMLOutputter when configured with
>
> xmlSerializer = new
> XMLOutputter(Format.getRawFormat().setExpandEmptyElements(true))
>
> doubles CR (carriage return) line breaks in the output, i.e. if I have
> an element
>
> <data>first line\r\nsecond line</data>
>
> will be outputted as
>
> <data>first line&#xD;\r\nsecond line</data>
>
> This results in a double CR if read in again with a different XML
> parser (libxml2 for example).
>
> I found an explanation in
> http://www.jdom.org/pipermail/jdom-interest/2003-July/012593.html but
> I miss the point in this processing?!
> What does TextMode.PRESERVE - which is the default according to the
> Javadoc - really mean (as it obviously doesn't preserve the text)?
> How can I really preserve the text in elements as-it-is?
>
> thanks in advance & best regards,
> christian
>   

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.