XSD <xsd:all> Type Mapping

As per the X.694 standard, the XSD all type is mapped to an ASN.1 SEQUENCE type with a special element add named order. This is added as a special element to the generated C# class with the name _order. This contains an index entry for each element that identifies the order elements are to be serilaized in when encoded in XML. By default, the array is initialized to encode the elements in the same order as specified in the type. When an XML document of this type is decoded, the order in which the elements are received in recorded in this array. If the data is serialized out in binary form (BER or PER) the array is included in the encoding. If is only transparent in XML encode/decode operations to mimic the behavior of its handling in XSD.

An example of how this is used might be a gateway application that read XML data and then translated to binary form for transmission over a low bandwidth network. When received on the other end, the receiving application would transcode back from binary to XML. Suppose the item being transmitted was described using an xsd:all type that had three elements: a, b, and c. When the original XML document was received by the sending application, suppose the elements were received in the order c, b, a. The order array would record this fact and it would be included in the binary serialization. When the receiver decoded the message on the other end, the order information would be available along with the element data. The receiver could then reconstruct the XML document with the items in the same order as received.