// xmlsort: swiss army knife xml ordering utility

Goal

Sort an xml file or parts of it to avoid false positive differences comparing it with a previous version (stored in a version control system like GIT or Mercurial).

Did you have some experience changing 1 thing only in a server, dump again data and obtain dozens of changed files like this ?

diff --git a/geonode.xml b/geonode.xml
index f4fc60f..ffcdbfc 100644
--- a/geonode.xml	2012-10-24 09:25:42.198961002 +0200
+++ b/geonode.xml	2012-10-24 09:26:58.034957830 +0200
@@ -19,12 +19,12 @@
     <entry key="namespace">http://geonode.org/</entry>
     <entry key="schema">the_schema</entry>
     <entry key="Loose bbox">true</entry>
-    <entry key="Expose primary keys">false</entry>
     <entry key="fetch size">1000</entry>
     <entry key="Max open prepared statements">50</entry>
+    <entry key="Expose primary keys">false</entry>
+    <entry key="user">MYUSER</entry>
     <entry key="preparedStatements">false</entry>
     <entry key="Estimated extends">true</entry>
-    <entry key="user">MYUSER</entry>
     <entry key="min connections">1</entry>
   </connectionParameters>
   <__default>false</__default>

xmlsort helps you to avoid this very annoing situations.

Dependencies

xmlsort depends from libxml2 and argparse libraries.

The program

xmlsort is a single python program.

It can work in some different ways:

  • called without filtering arguments sort all elements of the xml file
  • called with <-i|--include> <xpath> <depth> argument[s] sort matching <xpath> elements only and their children recurring <depth> times
  • called with <-x|--exclude> <xpath> argument[s] sort all elements except elements matching <xpath> and their children

How it works

xmlsort follow few simple steps.

For each node matching –include <xpath> arguments or all if –include is not defined:

  • sort alphabetically attributes of the starting tag
  • if there are sub-elements:
    • recure into each of them (accordingly with the <depth> and with –exclude arguments)
    • sort all sub-elements following the rules:
      • sort all sub-elements comparing tag names
      • if equal comparing attributes name
      • if equal comparing attribute contents
      • if equal comparing sub-elements

Limitations

  • All kind of implicit sorted lists are not supported (defined by xml schema)
  • Standard input is not supported
  • Packaging is still missing

References

Comments

Stuartrago
No. 1 @ 2016/10/18 12:53

central florida health care <a href=http://www.onweb.fr/?company_id=17296>acheter meridia en france</a> what does orthopedic doctor do

DouglasGOx
No. 2 @ 2016/11/11 10:19

my brother is a drug addict <a href=http://reductil.creatupropiaweb.com/>donde comprar reductil en chile</a> brand name viagra online

Williamlow
No. 3 @ 2016/12/13 18:39

advocate health care email <a href=http://rivotril.asso-web.com/>acheter rivotril gouttes belgique</a> what is orthopedic doctor

Anthonyst
No. 4 @ 2016/12/14 09:03

oxford healthcare jackson ms <a href=http://reductil.oneminutesite.it/>comprare reductil online</a> tips on how to pass a drug test

Charleskr
No. 5 @ 2016/12/15 02:34

anti anxiety prescription drugs <a href=http://trankimazin.mex.tl/>http://trankimazin.mex.tl/</a> pass a drug test in a day

RobertFug
No. 6 @ 2016/12/15 16:49

emergency medicine residency programs list <a href=http://adderall.onlc.be/>acheter adderall en ligne</a> medco prescription phone number

StevenMt
No. 7 @ 2016/12/16 14:57

prescription strength anti inflammatory <a href=http://methylphenidate.eventsbot.com/>buy methylphenidate</a> polaroid 7 inch tablet reviews

CharlesFub
No. 8 @ 2016/12/31 14:34

health benefits of ginger root <a href=http://tavor.soup.io/>tavor kaufen schweiz</a> hemp seeds drug test

CharlesFub
No. 9 @ 2017/01/02 23:20

watson 387 white pill <a href=http://www.stesolid.cybersite.nu/>kopa stesolid pa natet</a> buy soma online without a prescription

CharlesFub
No. 10 @ 2017/01/10 11:29

yasmin birth control pill <a href=http://rivotril.bloggo.nu/>kjope rivotril</a> 30 inch medicine cabinet

CharlesFub
No. 11 @ 2017/01/11 00:45

doctor who series 2 <a href=http://meridia.top-depart.com/>acheter meridia en france</a> best note taking tablet

Leave a comment…



  • E-Mail address will not be published.
  • Formatting:
    //italic//  __underlined__
    **bold**  ''preformatted''
  • Links:
    [[http://example.com]]
    [[http://example.com|Link Text]]
  • Quotation:
    > This is a quote. Don't forget the space in front of the text: "> "
  • Code:
    <code>This is unspecific source code</code>
    <code [lang]>This is specifc [lang] code</code>
    <code php><?php echo 'example'; ?></code>
    Available: html, css, javascript, bash, cpp, …
  • Lists:
    Indent your text by two spaces and use a * for
    each unordered list item or a - for ordered ones.