XML technologies / XML Schema / XML Schema element reference / xs:restriction (complex content)

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

Deriving a complex content model by restriction.

<xs:restriction
    base = xs:QName
    id = xs:ID
    {beliebige Attribute mit einem Nicht-Schema-Namensraum}
    >
    Content: (xs:annotation?, (xs:group | xs:all | xs:choice | xs:sequence)?,
    ((xs:attribute | xs:attributeGroup)*, xs:anyAttribute?))
</xs:restriction>

May occur within: xs:complexContent

Description

Restricting a complex type with complex content adds conditions to attributes and child elements, reducing the set of valid instance structures. It declares that a new content model is a subset of a base content model; schema processors check this declaration. The new model is described completely under xs:restriction and must restrict what the base model allowed: any content valid under the restricted type must also be valid under the base type. The only exceptions are attributes, whose descriptions under xs:restriction may be omitted if unchanged.

Restrictions

To simplify schema processors’ checks, the derived content model must follow the base type’s definition particle by particle. Each case must be an explicit derivation by restriction.

The same element name (xs:restriction) is used in three contexts with very different meanings. Carefully distinguish restriction of a simple data type, a simple content model and a complex content model.

Example

<xs:element name="author">
    <xs:complexType>
        <xs:complexContent>
            <xs:restriction base="person">
                <xs:sequence>
                    <xs:element ref="name"/>
                    <xs:element ref="born"/>
                    <xs:element ref="dead" minOccurs="0"/>
                </xs:sequence>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
</xs:element>

Attributes

base
Qualified name of the base type.

id
Element ID according to W3C XML Schema.

   

 

 

 

back to top