[jdom-interest] Formatting differences after migrating to JDOM2

Rolf jdom at tuis.net
Sun Sep 29 08:26:17 PDT 2013


Hi Robert.

This is surprising indeed, and I agree it should not be different from 
JDOM 1.x

Can you get me a copy of the input file and the relevant parts of Java 
code? You don't need to CC the whole list it is large...

Thanks

Rolf

On 29/09/2013 10:42 AM, Robert Krüger wrote:
> Hi,
>
> I just migrated my code to from JDOM to JDOM2 and noticed some of our
> unit tests failed. The reason is different formatting. I used
> Format.getPrettyFormat().setTextMode(PRESERVE) for the formatting and
> with jdom this produced output like the following
>
> <av-container format-version="0.3.4">
>    <container-format>MP4</container-format>
>    <bitrate>646448</bitrate>
>    <duration>2002002</duration>
>    <start-time>0</start-time>
>    <acquisition-timestamp>1340887741000</acquisition-timestamp>
>    <stream>
>      <type>VIDEO</type>
>      <codec>H.264</codec>
> ...
>
> after replacing the imports by jdom2 I got
>
> <av-container format-version="0.3.4">
>    <container-format>
>      MP4
>    </container-format><bitrate>
>      646448
>    </bitrate><duration>
>      2002002
>    </duration><start-time>
>      0
>    </start-time><acquisition-timestamp>
>      1340887741000
>    </acquisition-timestamp><stream>
>      <type>
>        VIDEO
>      </type><codec>
>        H.264
>      </codec>...
>
> This looks rather broken as it does not preserve the original data at
> all with all those added newlines. Removing the setTextMode(PRESERVE)
> restored the format to what is shown above but the reason I added
> setTextMode(PRESERVE) was that without it, whitespace was trimmed and
> I do not want that for elements with text content.
>
> Is this a bug? How can I achieve what I want, i.e. have a "pretty",
> i.e. indented format and have text-only elements preserve whitespace?
>
> Thanks in advance,
>
> Robert
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
>



More information about the jdom-interest mailing list