Re: Derivation by restriction wrt to type inheritance

"Martin Bernauer" <bernauer@dke.uni-linz.ac.at> writes:

> Concerning derivation by restriction most samples are 'easy' samples
> restricting complex types, e.g. by changing number of allowed occurences, or
> simple types.
> 
> My question now is the following:
> Is it allowed to change the type of an element "b" declared at complex type
> "B", when deriving a new complex type "R" from "B" by restriction, and
> setting the type of "b" to a subtype of its former type?
> 
> Or more concrete by the means of an example:
> I define complex types Person and a complex type Staff (a subtype of
> Person), furthermore a complex type for a list of persons, PersonList. I now
> want to derive a new complex type StaffList from PersonList, restricting the
> type of its only element "entry" from Person to Staff.

Yes, that should be possible.

> For me this is definitely a derivation by restriction, nevertheless IBMs
> schema quality checker rejects it, and I suppose XML Spy has limitations
> concerning derivation by restrictions (it accepts the schema below).
> 
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified" attributeFormDefault="qualified"
> targetNamespace="http://sample.org" xmlns:sam="http://sample.org">
>    <xs:complexType name="Person">
>       <xs:sequence>
>          <xs:element name="name"/>
>       </xs:sequence>
>    </xs:complexType>
>    <xs:complexType name="Staff">
>       <xs:complexContent>
>          <xs:extension base="sam:Person">
>             <xs:sequence>
>                <xs:element name="ssnr"/>
>                <xs:element name="address"/>
>             </xs:sequence>
>          </xs:extension>
>       </xs:complexContent>
>    </xs:complexType>
>    <xs:complexType name="PersonList">
>       <xs:sequence>
>          <xs:element name="entry" type="sam:Person"/>
>       </xs:sequence>
>    </xs:complexType>
>    <xs:complexType name="StaffList">
>       <xs:complexContent>
>          <xs:restriction base="sam:PersonList">
>             <xs:sequence>
>                <xs:element name="entry" type="sam:Staff"/>
>             </xs:sequence>
>          </xs:restriction>
>       </xs:complexContent>
>    </xs:complexType>
> </xs:schema>

Ah, but Staff is not a restriction of Person, it's an extension.

To achieve your goal, you need to:

a) Declare <entry> at the top level (you may want to make it
   abstract);
b) Declare <xs:element name='staff' type='sam:Staff'
                      substitutionGroup='sam:entry'/>
c) change StaffList to have
    <xs:element ref='sam:staff'/>
   as its content model.

If the namechange (from <entry> in the general case to <staff> in the
restricted case) is not acceptable, then you can't derive StaffList
from PersonList, I'm afraid.

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/

Received on Wednesday, 21 November 2001 06:40:20 UTC