Content Models

Contact Us or call 1-877-932-8228
Content Models

Content Models

Content models are used to indicate the structure and order in which child elements can appear within their parent element. Content models are made up of model groups. The three types of model groups are listed below.

  1. xs:sequence - the elements must appear in the order specified.
  2. xs:all - the elements must appear, but order is not important.
  3. xs:choice - only one of the elements can appear.

xs:sequence

The following sample shows the syntax for declaring a complex-type element as a sequence, meaning that the elements must show up in the order they are declared.

Syntax

<xs:element name="ElementName">
	<xs:complexType>
		<xs:sequence>
			<xs:element name="Child1" type="xs:string"/>
			<xs:element name="Child2" type="xs:string"/>
			<xs:element name="Child3" type="xs:string"/>
		</xs:sequence>
	</xs:complexType>
</xs:element>

xs:all

The following sample shows the syntax for declaring a complex-type element as a conjunction, meaning that the elements can show up in any order.

Syntax

<xs:element name="ElementName">
	<xs:complexType>
		<xs:all>
			<xs:element name="Child1" type="xs:string"/>
			<xs:element name="Child2" type="xs:string"/>
			<xs:element name="Child3" type="xs:string"/>
		</xs:all>
	</xs:complexType>
</xs:element>

xs:choice

The following sample shows the syntax for declaring a complex-type element as a choice, meaning that only one of the child elements may show up.

Syntax

<xs:element name="ElementName">
	<xs:complexType>
		<xs:choice>
			<xs:element name="Child1" type="xs:string"/>
			<xs:element name="Child2" type="xs:string"/>
			<xs:element name="Child3" type="xs:string"/>
		</xs:choice>
	</xs:complexType>
</xs:element>
Next