This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author alex.henderson
Recipients alex.henderson, eric.snow
Date 2013-07-07.14:23:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1373206994.89.0.82581289096.issue17372@psf.upfronthosting.co.za>
In-reply-to
Content
I have attached a proposed patch.

This makes some design decisions which I would like someone to review:
 a) To incorporate pretty-printing into the main write() method rather than adding a separate toprettyxml() method. Disadvantages: greater complexity of _serialize_xml(). Advantages: Reduced duplication of code, easy to add other pretty-printing (eg HTML) in the same way.
 b) Existing whitespace on the ends of existing text is mutated. Disadvantages: existing whitespace content may get changed. Advantages: Greater readability (which is the whole point), idempotence of pretty-printing.
 c) Not to add a trailing newline. I am undecided as to whether this is a bad idea or a good one, but am documenting it to ensure it gets visibility.

Of these, I think b) is the only potentially controversial one, and notably its behaviour differs from minidom's toprettyxml. I think it's the right thing to do though; and for the cases where whitespace is important, perhaps we can respect the xml:space attribute when pretty-printing?
http://www.w3.org/TR/xml/#sec-white-space

If these design choices are deemed suitable I'm happy to update the patch to support pretty-printing HTML also.
History
Date User Action Args
2013-07-07 14:23:14alex.hendersonsetrecipients: + alex.henderson, eric.snow
2013-07-07 14:23:14alex.hendersonsetmessageid: <1373206994.89.0.82581289096.issue17372@psf.upfronthosting.co.za>
2013-07-07 14:23:14alex.hendersonlinkissue17372 messages
2013-07-07 14:23:14alex.hendersoncreate