Sean O'Dell wrote:
> Dossy has a point, although pretty printing XML is problematic in
> itself.  If there are sub-keys, it's often assumed the parent key
> doesn't have data so the whitespace doesn't matter.  Most pretty
> printing I've seen ignores extra parent whitespace and just makes sure
> the keys with data and no sub-keys is tight.

Right.  We'll get nice pretty printing; I haven't worked on it much, but it 
should be improved.  I'm working with Dossy right now on narrowing down 
what he expects from pretty printing, then I'll submit it and see what 
people think.  That's why we have a development branch of REXML :-)

However, I too have a point.  Any time you insert whitespace to do pretty 
printing, you're changing the document.  Pretty printing is not a 
transitive operation, for "correct" XML processors, because (according to 
the XML spec) the processor must always report all whitespace to the 
application.

There is a solution.  I've had an (unrelated) feature request to add 
something that strips out whitespace-only text nodes; something like:

   d = Document.new(source1, {:strip_whitespace_nodes => true})
   d = Document.new(source2, {:strip_whitespace_nodes => %w{ el1 el2 el3 }})

I'm probably going to use this sort of API, unless I hear any more intuitive 
suggestions.

It won't guarantee transitivity, but it will improve the odds :-)

--- SER