I was wondering if it's possible to deep sort an XML (with attributes) on element names without knowing the structure of the XML or the element names. The sorting should be only based on XML Elements and not the attributes. Thanks
Example XML:
<Customer>
<CustomerID>ALFKI</CustomerID>
<Order>
<OrderID>10692</OrderID>
<CustomerID>ALFKI</CustomerID>
<OrderDate>1997-10-03</OrderDate>
</Order>
<CompanyName>Alfreds Futterkiste</CompanyName>
</Customer>
Result Expected:
<Customer>
<CompanyName>Alfreds Futterkiste</CompanyName>
<CustomerID>ALFKI</CustomerID>
<Order>
<CustomerID>ALFKI</CustomerID>
<OrderDate>1997-10-03</OrderDate>
<OrderID>10692</OrderID>
</Order>
</Customer>
Update: Actual XML
<NAB>
<jcr:content>
<par>
<color>
<title>
<![CDATA[Rouge sangria]]>
</title>
<code>
<![CDATA[NAB]]>
</code>
<image_url>
<![CDATA[/assets/2016/x6/colors/exterior/nab.jpg]]>
</image_url>
</color>
</par>
</jcr:content>
</NAB>
UPDATE:
I just found out that sorting a specific section of XML (under an element/tag <Handling>
) screws up things. Is it possible to modify the XSLT to avoid everything under (all the children of) <Handling>
?