Sorting of XSD-based elements already in the correct order

If the children of an element are in an order that matches the XSD, Gosu does not sort the element list. This is important if there is more than one sorted order that conforms to the XSD and you expect a particular order.

Example

The following XSD defines two distinct strict orderings of the same elements:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="Element1">
    <xsd:complexType>
      <xsd:choice>
        <xsd:sequence>
          <xsd:element name="A" type="xsd:int"/>
          <xsd:element name="B" type="xsd:int"/>
          <xsd:element name="C" type="xsd:int"/>
        </xsd:sequence>
        <xsd:sequence>
          <xsd:element name="C" type="xsd:int"/>
          <xsd:element name="B" type="xsd:int"/>
          <xsd:element name="A" type="xsd:int"/>
        </xsd:sequence>
      </xsd:choice>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

The following code assigns values to the child elements of the parent element in two different orders that are both valid:

uses examples.pl.gosu.xml.myschema.Element1

var xml = new Element1()
xml.A = 5
xml.B = 5
xml.C = 5
xml.print()
print( "----------" )
xml = new Element1()
xml.C = 5
xml.B = 5
xml.A = 5
xml.print()

This code prints the following:

<?xml version="1.0"?>
<Element1>
  <A>5</A>
  <B>5</B>
  <C>5</C>
</Element1>
----------
<?xml version="1.0"?>
<Element1>
  <C>5</C>
  <B>5</B>
  <A>5</A>
</Element1>