Complex Type: Elements That Contain Child Elements

An element that contains only child elements is classified as a complex type element. For example, the XML document declaration in the code snippet on the right indicates that the EmpName element contains two simple type elements, firstname and lastname.

The code snippet on the right also declares the associated XML schema declaration. In this declaration, the complexType element indicates that the EmpName element is a complex element. In addition, the declaration indicates that the complexType element contains two simple type elements, firstname and lastname.

Note that the xs:sequence element has been used before the firstname element declaration. The <xs:sequence> tag declares that the firstname and lastname elements must appear in the specified order within the DeptDetails element. The <xs:sequence> tag is an order indicator.

XML Document Declaration
--------------------------------------------

  <EmpName>
    <firstname>ABC</firstname>
    <lastname>DEF</lastname>
  </EmpName>

XML Schema Declaration
----------------------------------------

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

Click the Next button to continue.