[jdom-interest] Problem with XMLOutputter beta

Alec Hothan ahothan at cisco.com
Thu Jul 5 11:22:14 PDT 2001


Rather than trying to fit in any possible formatting, wouldn't it be better to make
this customizable using either subclassing of XMLOutputter or delegation? In both
cases, XMLOutputter has to be designed for (i.e. the method(s) to be subclassed must
be clearly documented or there should be a method to add a delegate interface).

-Alec



Jason Hunter wrote:

> stephan.segschneider at snellwilcox.com wrote:
> >
> > I have just converted my application back to JDOM beta 6. Using the following
> > code does solve my problem completely. You can mess up the formatting of an
> > existing XML file with any text editor (add spaces, add newlines, add tabs
> > whatsoever) and after loading the XML via SaxBuilder and writing it via the code
> > shown below you will get everything repaired - formatted the way you expect it -
> > indentation four spaces, no additional empty lines between elements AND all the
> > text data *untouched*!
> >
> >         fileWriter = new FileWriter(location);
> >         XMLOutputter outputter = new XMLOutputter("    ", true);
> >         outputter.setTrimText(false);
> >         outputter.setExpandEmptyElements(false);
> >         outputter.output(doc, fileWriter);
>
> Pretty formatting is done by adding and removing text whitespace -- so I
> don't see how you can say everything's formatted nicely and text data is
> untouched.  Some text nodes are definitely being touched.  Given the
> flags above you're adding whitespace without ever removing any, so a
> pretty printed document read in and output this way will be whitespace
> padded even tho it's not necessary.
>
> -jh-
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com




More information about the jdom-interest mailing list