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

Andriy Palamarchuk apa3a at yahoo.com
Thu Dec 6 05:21:12 PST 2001


Jason, thank you for the response.

Bradley, sorry I'm slow with responding on your the
last message.

Bradley S. Huffman wrote:
> Andriy Palamarchuk writes:
>>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.

Sorry for not being clear. This is about the outputter
only.

>>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.


Here I mean risk that the developer does not realize
that by changing whitespaces meaningful content of the
tags is changed. This is not the case on level (2).
Example - a developer wants to print nicely formatted
XHTML and decides to go with trimming level (3) or
(4). Possible problem - changing whitespaces in text,
included in <pre> tags.

>>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).

You are right, the default behavior is simple but the
nice-printing logic is not so obvious.

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

As we discussed earlier there are 2 separate
questions:
1) where to trim the whitespaces?
2) how to format?
Do we have the problem with formatting because we do
not answer directly question (1)?
It is clear what to do with inserting intendation and
newlines is clear as soon as we know where to insert
them.

As Jason suggested, there can be one more answer for
the second question - print compressed output. The
exact format again depends on answer on question (1).

Andriy Palamarchuk

__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com



More information about the jdom-interest mailing list