Sean Russell wrote:

> Dossy wrote:
> 
>>Does this one not break the XML document?  AFAIK, the current pretty
>>printer does NOT output a document that's identical to the one
>>represented in memory:
>>
> 
> All pretty printers "break" the XML document, if by "break" you mean 
> changing the text nodes.  By definition, that's what pretty printing does.
> 
> I'm not sure how well Thomas' works; I scanned it for potential nasty 
> behavior, and then included it in the configs. I haven't played around with 
> it much.  It does add line breaks, though.
> 
> 
>>Or, something like that.  What the pretty-printer really
>>needs to output is:
>>
>><blah>
>>  <foo>abc</foo>
>>  <bar>def</bar>
>></blah>
>>
> 
> Hmmm?  This doesn't produce an identical document, either, because it adds 
> whitespace which isn't ignored.
> 
> http://www.w3.org/TR/REC-xml#sec-white-space
> "An XML processor must always pass all characters in a document that are not 
> markup through to the application."
> 
> So, with:
> 
> 
>><blah><foo>abc</foo><bar>def</bar></blah>
>>
> 
> your preferred output
> 
> 
>><blah>
>>  <foo>abc</foo>
>>  <bar>def</bar>
>></blah>
>>
> 
> becomes
> 
> <blah>\n  <foo>abc</foo>\n  <bar>def</bar>\n<blah>


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.

	Sean