#25 [xhtml]

Restricting Complex Types - Example #2

We can also remove optional parts completely:

<xs:complexType name="Product">
   <xs:sequence>
      <xs:element name="number" type="xs:string"/>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="size" type="my:Size" minOccurs="0"/>
      <xs:element name="color" type="my:Colors" minOccurs="0"/>
   </xs:sequence>
</xs:complexType>

Here we restrict the product to the mimimal required parts:

<xs:complexType name="MinimalProduct">
   <xs:complexContent>
   <xs:restriction base="my:Product">
   <xs:sequence>
      <xs:element name="number" type="xs:string"/>
      <xs:element name="name" type="xs:string"/>
   </xs:sequence>
   </xs:restriction>
   </xs:complexContent>
</xs:complexType>