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.

classification
Title: Sort nodes when writing to file
Type: Stage:
Components: XML Versions: Python 2.4
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: effbot, jstrom
Priority: normal Keywords: patch

Created on 2005-11-14 13:58 by jstrom, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
minidom.py.sort-patch jstrom, 2005-11-14 13:58 Patch to sort XML Nodes when writing.
Messages (3)
msg49046 - (view) Author: Johan Ström (jstrom) Date: 2005-11-14 13:58
Regarding xml/dom/minidom.py

Noticed that the minidom's writer functions sorted the
attributes, but not the nodes, when writing (to file or
other). This resulted in XML files having nodes in
different order each time it was written (or at least
not sorted, in OSX the nodes came in different order
each time).
This could maybe be a problem with ie. files that seemd
to change when there realy isn't any content changes.
If not, its just better looking to have them sorted.
Wrote a patch for it if anyone wants to use it or add
it to the repository. Can't say that I've done any
extensive testing tho, if anyone sees any problems with
it, please tell!
msg49047 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2005-11-14 16:56
Logged In: YES 
user_id=38376

The element order tends to be pretty important in most XML
formats.

If applied to e.g. a simple XHTML file, your patch would place
all text nodes first in the body, followed by all headers, and
finally all paragraphs. I'm not sure a human reader would
agree that the resulting document looks better...
msg49048 - (view) Author: Johan Ström (jstrom) Date: 2005-11-14 17:31
Logged In: YES 
user_id=1378372

Doh... I was to focused on my specific usage. 
History
Date User Action Args
2022-04-11 14:56:14adminsetgithub: 42593
2005-11-14 13:58:31jstromcreate