Latest web development tutorials

XML Schema complexContent element

XML Schema Reference Complete XML Schema Reference

Definition and Usage

complexContent element defines extensions or restrictions on a complex type (with mixed content or contain only elements).

Element Information

  • Parent element: complexType

grammar

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

>

(annotation?,(restriction|extension))

</complexContent>

(? Sign declares that the element can occur zero or one time within complexContent element.)

属性 描述
id 可选。规定该元素的唯一的 ID。
mixed 可选。规定是否允许字符数据出现在该 complexType 元素的子元素之间。 默认值为 false。
any attributes 可选。规定带有 non-schema 命名空间的任何其他属性。

Example 1

The following example has a complex type "fullpersoninfo", this complex type by extension with three additional elements inherited type from another complex type "personinfo" derived from:

<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, "employee" element must contain the following elements in order: "firstname", "lastname", "address", "city" and "country".


XML Schema Reference Complete XML Schema Reference