[jdom-interest] XMLOutputter

Elliotte Rusty Harold elharo at metalab.unc.edu
Mon Jul 31 03:25:00 PDT 2000

>  Some subtle problems get introduced into XMLOutputter now that we
>handle whitespace correctly. By default, right now, XMLOutputter no
>longer does any indentation or line feeds. This may seem horribly wrong
>- all docs look all jumbled right? Well, actually, no!
>  Documents read in from an existing file (like contents.xml in the
>samples directory) come in now with whitespace and formatting preserved.
>So outputting that with the new XMLOutputter means it comes out as it
>came in (which is good - something we couldn't do even a day ago). This
>is because we finally hold onto whitespace and such.
>  The problem is that documents created in memory are the exact opposite
>- they need the indentation and new lines that XMLOutputter uses. So it
>(XMLOutputter) really needs different "defaults" based on the use-case.
>>From scratch docs needs the older version with indents and newlines,
>existing docs need no formatting.
>  Thoughts?

I don't think anybody denies that. The question that's up in the air, 
and I've sort of been waiting for you and Jason to weigh in on before 
moving forward is how to implement those defaults. Myself and about 
two or three others think that the way to go is to wrap all the 
formatting options in a separate class like the  OutputFormat class 
in Xerces and the similar class in Enhydra Jason mentioned. Alex 
hates this idea, and wants to put all the formatting methods directly 
on XMLOutputter. I'm hesitant to move forward until we get this 

To me it just seems more convenient to wrap all the different options 
into one class and into single objects. It's a little more modular 
and somewhat easier to follow and learn if we don't store too much 
functionality in one class. Most importantly, a separate class makes 
it a lot easier to copy formatting options from one outputter to 
another or from a default set of options to an outputter. Alex I 
guess thinks this is an unnecessary level of indirection. One of the 
questions is whether anything except an outputter is ever likely to 
need formatting options, in which case the separation is a little 
more defensible.

| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |

More information about the jdom-interest mailing list