[jdom-interest] BUG: XMLOutputter inserts extra empty lines

Bradley S. Huffman hip at a.cs.okstate.edu
Thu Dec 6 06:45:40 PST 2001

Jason Hunter writes:

> I'm starting to think that instead of having separate flags we just have
> different modes with options:
> RAW: prints the document as it is in memory, default
> PRETTY: prints the document "pretty" (whitespace altered)
>   Option to change indent string (tab, spaces)
>   Option to change line width (72, 80, 0 for no wrap)
> COMPRESSED: prints the document with whitespace removed
> We might even implement it with subclasses of XMLOutputter to break out
> the code and allow others to subclass if they want special tweaking.  Or
> we might allow pluggable code units, which is more flexible than
> subclassing.  outputter.setWhitespaceLogic(xxx).
> Thoughts?

How about taking pluggablity a step further (since I need this functionality
for another project :), a way to map to different actions base
on namespace, local name, prefix, or whatever else might be useful.

Have a Action class/interface with a method for each JDOM construct.  Mabye
the same methods as in JDOMFactory, or maybe SAX events.

Then several tree walker/visitor type classes (like preorder, breadth-first)
with the ability to set a map of different Action classes.  The idea being
the action performed when we walk the JDOM tree can change based on what we

In the case of XMLOutputter this means we could have different formats
based on the tag name and what namespace it belongs too.


More information about the jdom-interest mailing list