I want to do something like this Can you transform unordered xml to match an xsd:sequence order? bu a little more complex than that. For example:
<person>
<addressList>
<address>
<city>Chicago</city>
<state>IL</state>
<zip>41111</zip>
</address>
<address>
<state>MO</state>
<zip>64521</zip>
<city>Kansas City</city>
</address>
</addressList>
<lastname>The BFG</lastname>
<firstname>1234567890</firstname>
</person>
I don’t have control in the schema so this sould match the schema, but when I try to deserialize throw an error… so the solution is use XSLT to transform this to match XSD format. I just want to get the same input but in different order for instance something like this:
Note that City in the 2nd address, first name, and last name was move.
<person>
<lastname>The BFG</lastname>
<firstname>1234567890</firstname>
<addressList>
<address>
<city>Chicago</city>
<state>IL</state>
<zip>41111</zip>
</address>
<address>
<city>Kansas City</city>
<state>MO</state>
<zip>64521</zip>
</address>
</addressList>
</person>
Based on the previous link (Transform XML into specified ordering (DTD -> XSD)), the only changes we have to make are the xml inside of XSLT document and the name of the root (Top for person) and the new XSLT look like: