[jdom-interest] Extra newlines removing

Jason Hunter jhunter at collab.net
Mon May 21 17:39:16 PDT 2001

Aleksey Nikolayev wrote:
> Is there a method in JDom, that allows you to get rid
> of those 'tabs' and 'newlines' on building a document?
> (Something kind of setTrimText() or setNewLines() for
> the builder/parser)?

There's nothing yet to strip on building, although we're considering
adding a method.  In XML whitespace is important, so JDOM by default
preserves whitespace.

What you can do is setTrimText() on the outputter to tell it that it's
OK to trim the whitespace and that results in a pretty print.  (Note in
the latest code from CVS it's now named setTextNormalize().)  Or better
still you can use the default settings of XMLOutputter which do not add
any whitespace, if you know the doc you're reading is already whitespace
formatted nicely.  That's more efficient since it's a raw output.

> Thank you guys for a wonderful JDOM API by the way. It
> took me 10 minutes to jump in and created a great
> shortcut in my application development.

Excellent!  :-)


More information about the jdom-interest mailing list