[jdom-interest] dealing with whitespace when appending elements

Neil Burnett neil at efc.be
Sun Dec 10 13:45:58 PST 2000


For now I guess I will just see if I can create a pretty temp xml Document
with the new Element then move the Element to the real Document before
XMLOutputting without indentation or white space. Let me know if you think
there is a problem with that, or you have a one (or two :-) liner that will
do it.

Thanks for your help.

Neil

.At 13:26 10/12/2000 -0800, Jason Hunter wrote:
>> Great! Except that if I want to preserve the pretty formatting (indentation
>> and whitespace), I find the XMLOutputter("  ",true) accumulates the
>> whitespace like this:
>
>Here's where XML's mandate that whitespace be preserved gets to be a
>serious pain in the rear.  Because the input was nicely formatted you
>want to apply *no* formatting to the output lets the additional
>formatting mess up the good input.  But... since you added new elements
>to the tree, you want those to have whitespace added to format them
>nicely.  So you're stuck.  Selecting raw output lets the inputted
>elements look good at the expense of the added, but pretty output makes
>the added look good at the expense of the inputted.
>
>I think the secret might be to flip the soon-to-be-addedtoggle to remove
>surrounding whitespace on input, then do pretty output.  Unless you care
>about surrounding whitespace, this will work.  If you do care about
>surrounding whitespace, then you need to output raw.
>
>BTW, XMLOutputter has a number of bugs regarding whitespace handling. 
>I've asked Alex to deal with them since he's the one who did most of the
>coding.  
>
>-jh-
>



More information about the jdom-interest mailing list