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

RE: What are complexContent restrictions made for ?

From: Mark Feblowitz <mfeblowitz@frictionless.com>
Date: Mon, 20 May 2002 09:40:57 -0400
Message-ID: <4DBDB4044ABED31183C000508BA0E97F040ABB82@fcpostal.frictionless.com>
To: "'Anton Mellit'" <anton_mellit@unitedthinkers.com>, Jeni Tennison <jeni@jenitennison.com>
Cc: xmlschema-dev@w3.org
Yes - but the down-side to derivation by restriction - at least for the way
it's currently handled in XML Schema - is that it requires maintenance. Each
derivation by restriction requires the content model of the restriction to
be duplicated as an initial step. After this, no change to the "parent" in
the derivation is reflected in the "child." You must add that content
yourself, using extreme care to ensure that every derivation-by-restriction
step correctly propagates desired content. 

For example, say  you have a "Person" and you derive from it an "Employee"
by restriction (presumably because you want to restrict out/down some of the
content). To do so, you copy the content model of Employee and
remove/restrict according to your needs. If  you later add a "MaritalStatus"
element to Person and if you want MaritalStatus propagated, you have to do
the propagation yourself - in the correct place in the content model, using
the same type or a proper derivation, etc. And if some other type was
derived by restriction from Employee, you'd have to propagate MaritalStatus
there, etc. As your models get more complex and your derivation tree more
bushy and/or deeper, maintaining the consistency of the derivation can
become burdensome.

In most cases, it's preferable to build up from simpler types a set of
derivations by extension. At least then you'll be assured that the shared
content will be consistent, with minimal effort on your part. There are
challenges there, too, since you will likely have to create multiple,
fine-grained types from which to compose your desired type, and since there
is no support in Schema for "multiple inheritance." You composition model
would not be purely derivation by extension, but some combination of that
and straight component composition.


Mark Feblowitz                                   	
XML Architect
       [t]   617.715.7231                                     	
       [f]   617.495.0188
Frictionless Commerce Incorporated 	
       [e]  mfeblowitz@frictionless.com
       [w] http://www.frictionless.com
       [m] 400 Technology Square, 9th Floor
             Cambridge, MA 02139 
Open Applications Group Incorporated
       [e]  mfeblowitz@openapplications.org
       [w] http://www.openapplications.org 

 -----Original Message-----
From: 	Anton Mellit [mailto:anton_mellit@unitedthinkers.com] 
Sent:	Saturday, May 18, 2002 3:50 PM
To:	Jeni Tennison
Cc:	xmlschema-dev@w3.org
Subject:	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:element name="child" type="xs:string" minOccurs="1"

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

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 Monday, 20 May 2002 09:41:37 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:02 UTC