- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Tue, 27 Nov 2001 18:40:32 +0000
- To: Eddie Robertsson <eddie@allette.com.au>
- CC: "Henry S. Thompson" <ht@cogsci.ed.ac.uk>, Martin Bernauer <bernauer@dke.uni-linz.ac.at>, <xmlschema-dev@w3.org>
Hi Eddie, > I'm still trying to get my head around all the rules for derivation > by restriction but should the above Person type really be a > derivation by extension from the base Object? > > I have two reasons for asking this question: > > 1) Since the base Object doesn't specify a type this means that it > will default to the anyType. Nope (I think you might be confusing what happens when you declare an *element* without a type, and what happens when you define a complex type without a restriction/extension, or perhaps misread and thought that Object was an element rather than a type). <xs:complexType name="Object" /> is equivalent to: <xs:complexType name="Object"> <xs:complexContent> <xs:restriction base="xs:anyType" /> </xs:complexContent> </xs:complexType> As you know, when you restrict complex content you have to list all the elements and attributes that you want to *permit*. So having an empty complex type definition is equivalent to not allowing any content or any attributes. That's why you need to derive by extension to add attributes and elements to it. >> <xs:element name="personList"> >> <xs:complexType> >> <xs:complexContent> >> <xs:restriction base="List"> >> <xs:sequence minOccurs="0" maxOccurs="unbounded"> >> <xs:element ref="person"/> >> </xs:sequence> >> </xs:restriction> >> </xs:complexContent> >> </xs:complexType> >> </xs:element> > > 2) My second reason is because (from what I can understand) in the > above restriction the intent is to use person elements instead of > entry elements. Doesn't the rules on restriction say that for this > to be valid then the type of the person element must be derived by > _restriction_ from the type of the entry element. In this case the > type of the person element (Person) is derived by _extension_ from > the type of the entry element (Object). When you have a substitution group, the particle that refers to the head of the substitution group (i.e. the event element) is effectively substituted for an xs:choice that lists all the members of the substitution group. So effectively the List type is as follows: <xs:complexType name="List"> <xs:sequence minOccurs="0" maxOccurs="unbounded"> <xs:choice> <xs:element ref="person" /> ... any other members of the entry substitution group ... </xs:choice> </xs:sequence> </xs:complexType> As you can see, you can validly derive by restriction to the personList content model from that expanded xs:choice, just by cutting out a few of the choices. So you can replace an element with an element from its substitution group no matter what derivation method was used to derive the type of the element. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Tuesday, 27 November 2001 13:43:07 UTC