XSD Composite Type - Only Elements

The "only contains elements" complex type element is an element that can only contain other elements.

Complex types only contain elements

XML elements, the "person" element, only contain other elements:

<person>
<firstname>John</firstname>
<lastname>Smith</lastname>
</person>

You can define the "person" element in this way in the schema:

<xs:element name="person">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="firstname" type="xs:string"/>
      <xs:element name="lastname" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

Please note this <xs:sequence> element. It means that the defined elements must appear in the order above in the "person" element.

Or you can set a name for the complexType element and let the type attribute of the "person" element refer to this name (if this method is used, several elements can refer to the same complex type):

<xs:element name="person" type="persontype"/>
<xs:complexType name="persontype">
  <xs:sequence>
    <xs:element name="firstname" type="xs:string"/>
    <xs:element name="lastname" type="xs:string"/>
  </xs:sequence>
</xs:complexType>