I need to edit some XML files, I'm OK with removing and setting, but I don't see if and how is it possible to sort XML file using only Augeas?

Has anyone done it, I am trying to avoid other resources than Augeas for now?

I am using puppet, ruby, shell scripts. I can use augeas in puppet, not only augtool.

This is my exact task:
sort elements on element name, attributes name, table and column

I have a large XML file which actually contains a lot of tables, this is example of one table:

```
<table name="validation_rule" numRows="6" remarks="" schema="public" type="TABLE">
  <column autoUpdated="false" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4">
    <child column="validation_rule_id" foreignKey="meta_field_name_validation_rule_id_fkey" implied="false" onDeleteCascade="false" table="meta_field_name"/>
    <child column="validation_rule_id" foreignKey="preference_type_validation_rule_id_fkey" implied="false" onDeleteCascade="false" table="preference_type"/>
    <child column="validation_rule_id" foreignKey="validation_rule_attributes_validation_rule_id_fkey" implied="false" onDeleteCascade="false" table="validation_rule_attributes"/>
  </column>
  <column autoUpdated="false" digits="0" id="1" name="rule_type" nullable="false" remarks="" size="25" type="varchar"/>
  <column autoUpdated="false" digits="0" id="2" name="enabled" nullable="true" remarks="" size="1" type="bool"/>
  <column autoUpdated="false" digits="0" id="3" name="optlock" nullable="false" remarks="" size="10" type="int4"/>
  <primaryKey column="id" sequenceNumberInPK="1"/>
  <index name="validation_rule_pkey" unique="true">
    <column ascending="true" name="id"/>
  </index>
</table>

```

This is how I delete from same sample file:

```
augtool> set /augeas/load/xml/lens "Xml.lns" 
augtool> set /augeas/load/xml/incl /home/ESSENT/i.camilovic/test/test.xml
augtool> load
augtool> rm /files/home/ESSENT/i.camilovic/test/test.xml/TopLevel/FooBar
augtool> save

```

Here is a code sample in puppet that we use for something else:

```
    augeas { "${name} ReverseBuild Threshold fails":
      lens    => 'Xml.lns',
      incl    => $config_file,
      context => "${context}/triggers/jenkins.triggers.ReverseBuildTrigger/threshold",
      changes => [
        "set name/#text 'FAILURE'",
        "set ordinal/#text '2'",
        "set color/#text 'RED'",
        "set completeBuild/#text 'true'",
      ],
      notify  => Exec['reload-configuration'],
      require => Augeas["${name} Upstream Projects"],
    }

```