Complex Type: Empty Elements

An empty element is classified as a complex type element. An empty element cannot have any content between the start and end tag. However, an empty element can contain an attribute. For example, the XML document declaration in the code snippet on the right indicates that the DeptDetails empty element contains a LocationID attribute.

The code snippet on the right also declares the associated XML schema declaration. In the XML schema declaration, the complexType element indicates that the DeptDetails element is a complex element. In addition, the declaration indicates that the complexType element contains the LocationID attribute.

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

  <DeptDetails LocationID="123" />

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

  <xs:element name="DeptDetails">
    <xs:complexType>
      <xs:attribute name="LocationID"
      type="xs:integer" />
    </xs:complexType>
  </xs:element>

Click the Next button to continue.