Freigeben über


<xsd:restriction> Element (simpleType) 

Defines constraints on a simpleType definition.

<restriction
  base = QName 
  id = ID 
  {any attributes with non-schema Namespace}...>
Content: (annotation?, (simpleType?, (minExclusive | minInclusive | 
maxExclusive | maxInclusive | totalDigits |fractionDigits | length | 
minLength | maxLength | enumeration | whiteSpace | pattern)*))
</restriction>

Attributes

  • base
    The name of a built-in data type, simpleType element defined in this schema (or another schema indicated by the specified namespace). The element containing the restriction element is derived from the type specified by the base value.

    The base value must be a qualified name (QName).

    Required.

  • id
    The ID of this element. The id value must be of type ID and be unique within the document containing this element.

    Optional.

Element Information

Number of occurrences

One time

Parent elements

simpleType,

Contents

annotation, fractionDigits, enumeration, length, maxExclusive, maxInclusive, maxLength, minExclusive, minInclusive, minLength, pattern, simpleType, totalDigits, whiteSpace

Example

The following example shows a simple type definition using restriction. (The simple type is derived from nonNegativeInteger and its maxInclusive value is set to 100.)

<xs:simpleType name="freezeboilrangeInteger">
  <xs:restriction base="xs:nonNegativeInteger">
    <xs:maxInclusive value="100"/>
  </xs:restriction>
</xs:simpleType>

Example

The following example shows a simple type definition that derives from the integer built-in type and has all the facets of integer (no restrictions).

<xs:simpleType name="myInteger">
  <xs:restriction base="xs:integer"/>
</xs:simpleType>

Example

The following example shows a simple type definition that derives from string and is an enumerated type. The set of values is restricted to specified values.

<xs:simpleType name="mountainbikesize">
  <xs:restriction base="xs:string">
    <xs:enumeration value="small"/>
    <xs:enumeration value="medium"/>
    <xs:enumeration value="large"/>
  </xs:restriction>
</xs:simpleType>

See Also

Reference

XML Schemas (XSD) Reference
XML Schema Elements