Complex Type: Elements That Contain Simple Content

An element that contains simple content is classified as a complex type element. For example, the XML document declaration in the code snippet on the right indicates that the EmpID element contains integer content and the country attribute.

The code snippet on the right also declares the associated XML schema declaration. In this declaration, the complexType element indicates that the EmpID element is a complex type element. The simpleContent element indicates that the complexType element contains only text and attributes. A simpleContent element must contain an extension or a restriction element. The restriction element limits the base data type to the specified data type. Similarly, an extension element extends the base data type of a complexType element.

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

  <EmpID country="USA">001345</EmpID>

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

  <xs:element name="EmpID">
    <xs:complexType>
      <xs:simpleContent>
        <xs:restriction base="xs:integer">
          <xs:attribute name="country"           type="xs:string"/>
        </xs:restriction>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

Click the Next button to continue.