Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-1542

Irregular ordering of document XML fields during export

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.1 M4
    • 1.1 M3
    • {Unused} Core
    • 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).

      Attachments

        1. sortedFieldsToXML.4055.patch
          16 kB
          Erin Schnabel
        2. sortedFieldsToXML.patch
          15 kB
          Erin Schnabel

        Activity

          People

            sdumitriu Sergiu Dumitriu
            ebullient Erin Schnabel
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: