XSD Composite Type - Only Contains Elements

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

Complex types only contain elements

The XML element, "person", only contains other elements:

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

You can define the "person" element like this 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>. 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>