XML technologies / XML Schema / XML Schema element reference / xs:restriction (simple type)
(Excerpt from “XML Schema” by Eric van der Vlist)
Deriving a simple data type 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:restriction>May occur within: xs:simpleType (local definition), xs:simpleType (global definition)
Description
Deriving a simple data type by restriction defines a new type by adding constraints, called facets, to a base data type, restricting its lexical and value spaces.
The base data type can be specified by reference, through attribute base, or inline through an xs:simpleType element defining a local data type.
Each facet is defined as a child element after the optional embedded xs:simpleType definition.
Each facet has its own meaning and acts on lexical space, value space or the whitespace transformation between lexical and value spaces. Its behavior may also vary with the base data type.
Restriction can apply to any type variety, atomic, list or union, without changing that variety: atomic, list and union data types remain atomic, list or union after restriction.
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.
Attribute base and the embedded xs:simpleType definition cannot both be used: the base type is defined either by reference or by embedding.
Example
<xs:simpleType name="myInteger">
<xs:restriction base="xs:integer">
<xs:minInclusive value="-2"/>
<xs:maxExclusive value="5"/>
</xs:restriction>
</xs:simpleType>Attributes
base
Qualified name of the base data type when defined by reference.
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