XML technologies / XML Schema / XML Schema element reference / xs:complexContent

(Excerpt from “XML Schema” by Eric van der Vlist)

Defining complex content by derivation from a complex type.

<xs:complexContent
    id = xs:ID
    mixed = xs:boolean
    {beliebige Attribute mit einem Nicht-Schema-Namensraum}
    >
    Content: ((xs:annotation?), (xs:restriction | xs:extension))
</xs:complexContent>

May occur within: xs:complexType (local definition), xs:complexType (global definition)

Description

This element defines a complex content model by derivation from a complex type. It is not itself a component, since complex contents are unnamed, but declares the intent to define a complex content model by derivation.

The derivation method is determined not by element xs:complexContent itself but by the choice of its child element: xs:restriction for restriction or xs:extension for extension.

This element can specify whether the content model is mixed, but this information can also be specified on parent element xs:complexType, which also has a mixed attribute.

The mixed character of the content model defined by element xs:complexContent depends on the derivation method and base type. A mixed base type can be restricted to element-only content; otherwise the base type’s mixed character cannot be changed.

Restrictions

If the base type is not mixable, ‹xs:complexContent mixed="true"› is not allowed.

Example

<xs:element name="author">
    <xs:complexType>
        <xs:complexContent>
            <xs:extension base="basePerson">
                <xs:sequence>
                    <xs:element ref="dead" minOccurs="0"/>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
</xs:element>

Attributes

id
Element ID according to W3C XML Schema.

mixed
If the value is true, the content model is mixed; if it is false, it is element-only; if unset, the content model is determined by attribute mixed of parent element xs:complexType.

   

 

 

 

back to top