Name

xs:restriction

Synopsis

<xs:restriction
  base = "QName"
  id = "ID">
  <!-- ( 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:group | xs:all | xs:choice | xs:sequence)?,
          ((xs:attribute | xs:attributeGroup)*, xs:anyAttribute?) )
       ) -->
</xs:restriction>

The xs:restriction element derives a new type from an existing base type identified by either a base attribute or an xs:simpleType child element. When deriving by restriction, all valid values of the derived type must also be legal values of the base type. However, the reverse is not true. The valid values of the derived type are a subset of the valid values of the base type. For derived simple types, the allowed values are identified by the various facet child elements of the xs:restriction element. For derived complex types, the allowed values are identified by the same elements you’d find inside an xs:complexType element—that is, zero or one group elements such as xs:all, xs:choice, or xs:sequence followed by attribute representation elements such as xs:attribute, xs:attributeGroup, and xs:anyAttribute.

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.