Re: What are complexContent restrictions made for ?

> Thus, deriving by restriction is helpful because it enables you to
> express the commonality between a set of elements, and process them in
> the same kind of way.

As I understand the idea of derivation is the following:
If type B is derived from type A then every element of type B can be
considered as an element of type A.

However, type definitions can be as follows:

<xs:complexType name="A">
    <xs:sequence>
        <xs:element name="child" type="xs:string" minOccurs="1"
maxOccurs="1"/>
    </xs:sequence>
</xs:complexType>

<xs:complexType name="B">
    <xs:complexContent>
        <xs:restriction base="A">
            <xs:sequence>
                <xs:element name="child" type="xs:string" minOccurs="0"
maxOccurs="0"/>
            </xs:sequence>
        </xs:restriction>
    </xs:complexContent>
</xs:complexType>

If I have element of actual type B, but think of it as of element of type A
then I will fail trying to get value of its element <child>. Please, correct
me if I am wrong.

Regards, Anton

Received on Saturday, 18 May 2002 15:51:16 UTC