XML technologies / XML Schema / XML Schema element reference / xs:restriction (simple content)
(Excerpt from “XML Schema” by Eric van der Vlist)
Deriving a simple content model by restriction.
<xs:restriction
base = xs:QName
id = xs:ID
{beliebige Attribute mit einem Nicht-Schema-Namensraum}
>
Content: (xs:annotation?, (xs:simpleType?, (xs:minExclusive |
xs:minInclusive | xs:maxExclusive | xs:maxInclusive |
xs:totalDigits | xs:fractionDigits | xs:length |
xs:minLength | xs:maxLength | xs:enumeration | xs:whitespace |
xs:pattern)*)?, ((xs:attribute | xs:attributeGroup)*,
xs:anyAttribute?))
</xs:restriction>May occur within: xs:simpleContent
Description
Restricting complex types with simple content adds conditions to both attributes and text nodes allowed in simple-content elements, reducing the set of valid instance structures. Text nodes are restricted with the same facets as simple types; attributes are restricted by listing changed attribute definitions or references. The attribute types in this list must be identical to those in the base type or explicitly derived from them by restriction. Conditions on attributes must restrict their definitions: a value may be fixed, for example, and an optional attribute may become required or forbidden.
Restrictions
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="title">
<xs:complexType>
<xs:simpleContent>
<xs:restriction base="tokenWithLangAndNote">
<xs:maxLength value="255"/>
<xs:attribute name="lang">
<xs:simpleType>
<xs:restriction base="xs:language">
<xs:enumeration value="en"/>
<xs:enumeration value="de"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:restriction>
</xs:simpleContent>
</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