W3C home > Mailing lists > Public > xmlschema-dev@w3.org > May 2002

Re: What are complexContent restrictions made for ?

From: Anton Mellit <anton_mellit@unitedthinkers.com>
Date: Sat, 18 May 2002 22:50:13 +0300
Message-ID: <004e01c1fea5$97cf03b0$0100a8c0@cpu>
To: "Jeni Tennison" <jeni@jenitennison.com>
Cc: <xmlschema-dev@w3.org>
> 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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:56 UTC