XML Schema complexContentElement


XML Schema 参考手册Complete XML Schema Reference Manual

Definition and Usage

The complexContent element defines extensions or restrictions on a complex type (which contains mixed content or only elements).

Element Information

  • Parent element: complexType

Syntax

<complexContent
id=ID
mixed=true|false
any attributes

>

(annotation?,(restriction|extension))

</complexContent>

(The ? sign declares that the element can appear zero or one time inside the complexContent element.)

Attributes Description
id Optional. Specifies a unique ID for the element.
mixed Optional. Specifies whether character data is allowed to appear between the child elements of this complexType element. The default value is false.
any attributes Optional. Specifies any other attributes with a non-schema namespace.

Example 1

In the following example there is a complex type "fullpersoninfo", which is derived from another complex type "personinfo" by extending the inherited type with three additional elements:

<xs:element name="employee" type="fullpersoninfo"/>

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

<xs:complexType name="fullpersoninfo">
  <xs:complexContent>
    <xs:extension base="personinfo">
      <xs:sequence>
        <xs:element name="address" type="xs:string"/>
        <xs:element name="city" type="xs:string"/>
        <xs:element name="country" type="xs:string"/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

In the above example, the "employee" element must contain the following elements in order: "firstname", "lastname", "address", "city", and "country".


XML Schema 参考手册Complete XML Schema Reference Manual Other Extensions