<xsd:restriction> Element (complexContent)

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>

Attributes

  • base
    The name of a complexType 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

complexContent

Contents

group, all, choice, sequence, attribute, attributeGroup, anyAttribute

Example

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>

See Also

Reference

XML Schemas (XSD) Reference
XML Schema Elements