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.
Copyright © 2003 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “XML Schema” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de