Defines constraints on a complexContent definition.
<restriction base = QName id = ID {any attributes with non-schema Namespace}…> Content: (annotation?, (group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)) </restriction>
The base value must be a qualified name (QName).
Required.
Optional.
Number of occurrences | One time |
Parent elements | complexContent |
Contents | group, all, choice, sequence, attribute, attributeGroup, anyAttribute |
The following example shows a complex type definition using restriction. The complex type, USAddress
, is derived from a general address complex type and its country element is fixed to US
.
<xs:complexType name="address"> <xs:sequence> <xs:element name="street" type="xs:string" /> <xs:element name="city" type="xs:string" /> <xs:element name="zipcode" type="xs:integer" /> <xs:element name="country" type="xs:string" /> </xs:sequence> </xs:complexType> <xs:complexType name="USAddress"> <xs:complexContent> <xs:restriction base="address"> <xs:sequence> <xs:element name="street" type="xs:string" /> <xs:element name="city" type="xs:string" /> <xs:element name="zipcode" type="xs:integer" /> <xs:element name="country" type="xs:string" fixed="US" /> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType>
XML Schema Reference (XSD) | XML Schema Elements
For more information, see the W3C XML Schema Part 2: Datatypes Recommendation at http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#derivation-by-restriction.