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

Re: Should this schema be invalid?

From: Jeni Tennison <jeni@jenitennison.com>
Date: Thu, 1 Aug 2002 11:09:26 +0100
Message-ID: <17863168811.20020801110926@jenitennison.com>
To: xmlschema-dev@w3.org, "Dare Obasanjo" <dareo@microsoft.com>

Hi Dare,

> Given the rules at
> http://www.w3.org/TR/xmlschema-1/#cos-particle-restrict it seems the
> following schema is invalid. Should it be?
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>            elementFormDefault="qualified">
>   <xs:complexType name="Person" > 
>        <xs:sequence> 
>          <xs:element name="name" type="xs:string" /> 
>          <xs:element name="age" type="xs:double" /> 
>          <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"  /> 
>        </xs:sequence> 
>      </xs:complexType> 
>   <xs:complexType name="WageSlave" > 
>       <xs:complexContent> 
>         <xs:restriction base="Person" > 
>           <xs:sequence> 
>             <xs:element name="name" type="xs:string" /> 
>             <xs:element name="age" type="xs:double" /> 
>             <xs:sequence> 
>               <xs:element name="ssn" type="xs:string" /> 
>               <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" /> 
>             </xs:sequence> 
>           </xs:sequence> 
>         </xs:restriction> 
>       </xs:complexContent> 
>     </xs:complexType> 
> </xs:schema>

As I see it, the mapping is:

  (name, age, #other*) -> (name, age, (ssn, #other*))

The sequence (ssn, #other*) counts as pointless because it has a
minOccurs and maxOccurs of 1 and it appears in another sequence, so
the mapping is actually:

  (name, age, #other*) -> (name, age, ssn, #other*)

The best functional mapping is then:

  name    -> name
  age     -> age
          -> ssn
  #other* -> #other*

which isn't valid because there's no particle in the base type for the
ssn particle to map on to.

OK, so that's why the schema is invalid based on the rules. Whether it
*should* be is a different question. I think that this is a clear
example of where the rules are highly non-intuitive and don't give the
"right answer": it's clear to a human that the ssn particle maps to
the wildcard and that the restriction should be valid. I think that
the definition of an order-preserving functional mapping needs to be
changed so that a particle in the base type can map to more than one
particle in the derived type, as long as the total cardinalities are
OK. Send along a suggestion to www-xml-schema-comments@w3.org?

However (just in case you were asking on behalf of the MSXML
developers), until there's an erratum issued that changes the way in
which derivations by restriction are assessed, I think validators
should continue to work by the rules rather than what gives the
results that the users want; it's bad enough having validators
behaving differently because of bugs, we don't need them to behave
differently because of added "features" as well.



Jeni Tennison
Received on Thursday, 1 August 2002 06:09:33 UTC

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