Purpose | This element allows restrictions to be imposed on
the datatype specified by the base attribute.
You can choose between twelve constraining facets, which are listed below in
the child elements section of this table.
|
Parent element | xs:complexContent ,
xs:simpleType |
Child elements |
These child elements represent the constraining facets that can be applied to restrict the value space of the new data type to be defined. |
Attributes | base |
Name | Type | Description |
---|---|---|
base |
xs:QName |
When you use the xs:restriction
element to derive a new simple type from an existing simple type (the base
type), the base attribute specifies the type
from which the derived type is derived. See the example below in which a new
type is derived from
xs:NMTOKEN by restriction.
|
This example shows a type definition of an enumeration type whose lexical
space contains the three values given as value arguments for the
xs:enumeration
element:
<xs:restriction base = "xs:NMTOKEN"> <xs:enumeration value = "instrumentalist"/> <xs:enumeration value = "jazzSinger"/> <xs:enumeration value = "jazzComposer"/> </xs:restriction>
This example defines a datatype for a financial application for expressing numerical values for monetary amounts ranging from -999,999,999.99 Euros to 999,999,999.99 Euros:
<xs:simpleType name="amount"> <xs:restriction base="xs:decimal"> <xs:totalDigits value="11"/> <xs:fractionDigits value="2"/> </xs:restriction> </xs:simpleType>