In the case of complex types, it is not quite so straightforward.
Unlike the extension process, it is necessary to completely reproduce
the parent type definition as part of the restriction definition. By
omitting parts of the parent definition, the restriction element
creates a new, constrained type. As an example, this
xs:complexType element derives a new type from the
physicalAddressType that only allows a single
street element to contain the street address. The
original physicalAddressType looks like:
<xs:complexType name="physicalAddressType">
<xs:sequence>
<xs:element name="street" type="xs:string" maxOccurs="3"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
</xs:sequence>
</xs:complexType>
The restricted version looks like:
<xs:complexType name="simplePhysicalAddressType">
<xs:complexContent>
<xs:restriction base="addr:physicalAddressType">
<xs:sequence>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
Notice that this type very closely resembles the
physicalAddressType, except the
maxOccurs="3" attribute has been removed from the
street element declaration.