[jdom-interest] Deprecating some XMLOutputter constructors
guru at stinky.com
guru at stinky.com
Wed Jun 20 14:30:10 PDT 2001
Alex -
Thanks for the writeup. I'm not sure your algorithm will work any
better than the current one -- that is to say, it will probably have
some cases it handles very well, and others that it can't handle
without a lot of special-case hacking. Pretty-printing is hard,
mostly because every permutation of document + programmer leads to a
different definition of "pretty" :-)
It's a little late in the game to change the XMLOutputter algorithm
wholesale. However, if you're inspired, I'd recommend that you make a
subclass of XMLOutputter that implements things your way. I'm pretty
sure you'd only have to override one method, printElementContent. If
you do this, please apply the patch I posted recently, which makes
that method's internals easier to understand, or wait a few days,
since I'll be doing some more refactoring to printElementContent that
should make your job easier.
Cheers -
- Alex
> Here's the algorithm I'd use for pretty-printing: For any element
> that has child elements, replace any text nodes that consist only of
> whitespace (or that are empty) with the necessary
> newline+indent. (In other words, we only modify whitespace-only
> mixed content nodes.) There would also be a separate option to
> normalize whitespace.
--
Alex Chaffee mailto:alex at jguru.com
jGuru - Java News and FAQs http://www.jguru.com/alex/
Creator of Gamelan http://www.gamelan.com/
Founder of Purple Technology http://www.purpletech.com/
Curator of Stinky Art Collective http://www.stinky.com/
More information about the jdom-interest
mailing list