Sorting XML file through multiple attributes
- by jbugeja
I want to sort a 'free-form' XML file through multiple attributes (first by T and then by L). The XML is a bit complex and it is structured as shown below:
<?xml version="1.0" encoding="utf-8"?>
<wb xmlns:cf="http://www.macromedia.com/2004/cfform" xmlns:a="urn:dummy">
<a:form name="chart">
<a:fieldset FIELD="a" FIELDNAME="FieldSet1">
<a:select1 FIELDNUMBER="01" L="1" T="2" />
<a:input FIELDNUMBER="02" INDEX="4" L="200" T="1" />
</a:fieldset>
<a:fieldset FIELD="b" FIELDNAME="FieldSet1">
<a:select1 FIELDNUMBER="03" T="3" L="1" />
<a:input FIELDNUMBER="04" INDEX="7" T="4" L="200" />
<a:fieldset FIELD="c" FIELDNAME="FieldSet1">
<a:input FIELDNUMBER="05" T="10" INDEX="6" L="400" />
<a:input FIELDNUMBER="06" T="8" INDEX="8" L="200" />
</a:fieldset>
</a:fieldset>
<a:input FIELDNUMBER="08" INDEX="3" L="3" T="5" />
<a:input FIELDNUMBER="09" INDEX="2" L="2" T="4" />
</a:form>
</wb>
PS:
The root element is wb and this is always followed by a:form
The L and T are always found in elements that have a tag in the namespace a, the only exception being a:fieldset which does not have L and T
a:fieldset could have multiple children of the namespace a including another a:fieldset
We can also assume that L denotes Left and T denotes Top. So, the idea of this is that when I view the transformed XML I can immediately note which elements precede what.
What's your take on this?