[jdom-interest] Re: bloated RC2 files - extra white space
Bradley S. Huffman
hip at a.cs.okstate.edu
Thu May 8 07:23:03 PDT 2003
Abe Mishler writes:
> Trimming preserves the data much better. Normalizing was just ...
> demoralizing? Here's the sick combination for getting just the right amount
> of whitespace outside of elements (for indenting) and preserving whitespace
> inside CDATA for anyone in the future:
>
> XMLOutputter outputter = new XMLOutputter(" ", true, "ISO-8859-1");
> outputter.setTextTrim(true);
There's a 4th option, setTrimAllWhite which might be closer to what you
want, any text with even one non-ws char is left as is.
XMLOutputter outputter = new XMLOutputter();
outputter.setEncoding("ISO-8859-1");
outputter.setIndent(" ");
outputter.setNewlines(true);
outputter.setTrimAllWhite(true);
Brad
More information about the jdom-interest
mailing list