Details
-
Bug
-
Resolution: Fixed
-
Major
-
1.1 M3
-
None
-
export, XML, field ordering, patch
-
Description
I've talked to Vincent about this a few times, I know it bugs him, too.
Any time you export a document to XML, the fields/objects/classes can come out in a different order. If you're working on a document-based application, for example, this seemingly harmless field flipping can make it very difficult to figure out what actually changed, and what didn't.
I've attached a patch that imposes a sort order on fields when rendered to XML (via iterators and comparators), in one case, I substituted a TreeMap for a vanilla HashMap to get intrinsic sorting of keys. The implementation is fairly clean: one new method on BaseCollection to get an iterator that will walk over the fields in a sorted collection. Fields are sorted by name (the getName method on the ElementInterface).