[jdom-interest] XML file formatting using XMLOutputter
jhunter at collab.net
Fri Jan 26 13:27:45 PST 2001
You point out a known problem, and one I've commented on before. It all
stems from XML's spec requirement that whitespace be preserved. Right
now you can set a flag on the outputter to trim whitespace on text and
that results in nicely formatted docs (so long as surrounding whitespace
is irrelevant). I agree it'd be nice to strip whitespace on input to
save memory for those times whitespace is irrelevant. If you read
TODO.txt you'll see that's on the list. If you want to help with the
impl to speed it along, you're welcome to. TODO describes alternate
> "Richard L. Cannon" wrote:
> I have been working with JDOM beta 5 and have come across a peculiar
> problem when trying to read in a document, modify it, and write it
> back out.
> I cannot get the document to have consistently clean formatting.
> If I read an XML document with newlines and indentations, add new
> elements to it, and write it back out, the output will not be
> formatted. If I the Outputter is instantiated to insert newlines and
> indentations, the new elements will look right, but the previous
> will now have double newlines and indentations.
> On the other hand, if the Outputter is instantiated to NOT insert
> or indentations, the previous elements will look right,
> indentations.but the
> new elements won't have any newlines or indentations.
> I think what I need is a way to read an XML document which has
> and indents, and strip all of them out before doing any modifications
> or writing
> the document back out.
> Has anyone else run into this problem or does anyone have a solution?
> Rick Cannon
> rick.cannon at jhuapl.edu
More information about the jdom-interest