This documentation is archived and is not being maintained.

Sequence Element Binding Support 

The .NET Framework provides binding support for the <sequence> element.

When generating classes from schema, the XML Schema Definition Tool (Xsd.exe) generates members of the class (fields or properties) in the exact order as they are listed in the <sequence> (or <all>) element. But when generating schema from a given class instance, the order of the members depends on the order in which the reflection engine returns them to the serializer. The order is not defined and is variable. To ensure the ordering of sequence in generated schema, set the Order property of the following attribute classes, as appropriate: XmlElementAttribute, XmlAnyElementAttribute, and XmlArrayAttribute. When generating classes from schema using the xsd.exe tool, you can use the /order command-line switch to generate the Order property automatically.

The <sequence> element provides an ordered grouping of elements defined using the <element> XSD element or certain other XSD elements. In contrast, the All Element Binding Support element provides an unordered grouping of a subset of the elements that the <sequence> element can contain.

When generating source code from an XML Schema document, the Xsd.exe utility produces public fields in the same order as the contents of the <sequence> element, or for that matter the <all> element.

When generating an XML Schema document from a set of classes in an assembly, Xsd.exe translates a class's public fields into the appropriate elements appearing under a <sequence> element in the same order as the fields appear in the class.

The assumption is that elements within a complex type should appear ordered, not unordered.

Possible Attributes Binding Support


The Xsd.exe utility ignores the id attribute, which is intended to provide a unique identifier.


For the <sequence> element, a maxOccurs value of 0 is interpreted by Xsd.exe as 1, and a maxOccurs value greater than 1 is interpreted as unbounded.

When using Xsd.exe with schemas that have multiply occurring sequences (sequences with maxOccurs greater than 1), use the /order command line option. For more information about why this is needed, see the MaxOccurs Attribute Binding Support attribute.


When generating source code from an XML Schema document, Xsd.exe ignores the minOccurs attribute if applied <sequence> element.

When generating an XML Schema document from classes, Xsd.exe does not specify a minOccurs value, reverting to the default 1.

See the MinOccurs Attribute Binding Support attribute.

Possible parent elements: <choice>, <complexType>, <extension>, <group>, <restriction>

Possible child elements: <annotation>, <any>, <choice>, <element>, <group>