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

Bradley S. Huffman hip at a.cs.okstate.edu
Fri Nov 30 13:06:30 PST 2001


Andriy Palamarchuk writes:

> 1) existence of xml:space attribute (BTW, does JDom
> checks for this attribute?)

XMLOutputter doesn't currently check for it, but I like it.

> I suggest to change concept of whitespace handling in
> such direction:
> 1) decide where and which spaces can be removed,
> remove them

So that we're all on the same wavelength, we're not talking about
changing the underlying JDOM structure or any JDOM nodes, just what
gets sent to the output stream.

> Such levels exists:
> 1) no trimming

Default.

> 2) trim empty text nodes (like described above in xslt
> specification

Hmmm, trimEmptyContent flag? Right now XMLOutputter doesn't have a 
option corresponding to this level.


> 3) (2) + trim leading/trailing whitespace	- (risky,
> but can work for some XML languages)
> 4) (3) + trim whitespaces in the text (*very* risky,
> not sure if we need this level)
> but by default I'd go with  level 2.

I don't see what's risky, if I tell XMLOutputter to trim w.s. (through
the set*() methods), that's what I want.

> We need for JDom some simple and predictable formatting behaviour.
> If somebody wants to do something more complex he can use tools,
> created for this purpose (XSLT).

Right now it is simple, the default constructor for XMLOutputter
gives you exactly what you created with no formatting or mangling
of *element* content in anyway (your level 1).

What seems to be the sticking point is what is meant by "pretty print"
(using setNewlines() and setIndent()).

I do have a new (and I think cleaner version) version of XMLOutputter
if anyone wants to play with it.

Brad



More information about the jdom-interest mailing list