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

[RESEND] Derivation by restriction

From: Dare Obasanjo <dareo@microsoft.com>
Date: Fri, 15 Mar 2002 20:23:33 -0800
Message-ID: <8BD7226E07DDFF49AF5EF4030ACE0B7E0557160B@red-msg-06.redmond.corp.microsoft.com>
To: "Xmlschema-Dev (E-mail)" <xmlschema-dev@w3.org>
[I sent this out a few weeks ago and got no response and decided to try again -- Dare] 
 
Our implementation of an XML schema validator considers the following document invalid

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema <http://www.w3.org/2001/XMLSchema> "
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Address">
  <xs:complexType>
   <xs:sequence>
    <xs:element name="aPossibleAddress" type="Address_t"/>
    <xs:element name="aRealAddress" type="EnteredAddress_t"/>
   </xs:sequence>
  </xs:complexType>
</xs:element>
<xs:complexType name="Address_t">
  <xs:sequence>
   <xs:element name="theAddressString" minOccurs="0">
    <xs:simpleType>
     <xs:restriction base="xs:string">
      <xs:maxLength value="50"/>
     </xs:restriction>
    </xs:simpleType>
   </xs:element>
  </xs:sequence>
</xs:complexType>
<xs:complexType name="EnteredAddress_t">
  <xs:complexContent>
   <xs:restriction base="Address_t">
    <xs:sequence>
     <xs:element name="theAddressString">
      <xs:simpleType>
       <xs:restriction base="xs:string">
        <xs:maxLength value="50"/>
       </xs:restriction>
      </xs:simpleType>
     </xs:element>
    </xs:sequence>
   </xs:restriction>
  </xs:complexContent>
</xs:complexType>
<xs:simpleType name="AddressString_t">
  <xs:restriction base="xs:string">
   <xs:maxLength value="50"/>
  </xs:restriction>
</xs:simpleType>
</xs:schema>

and considers this one as valid

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema <http://www.w3.org/2001/XMLSchema> "
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Address">
  <xs:complexType>
   <xs:sequence>
    <xs:element name="aPossibleAddress" type="Address_t"/>
    <xs:element name="aRealAddress" type="EnteredAddress_t"/>
   </xs:sequence>
  </xs:complexType>
</xs:element>
<xs:complexType name="Address_t">
  <xs:sequence>
   <xs:element name="theAddressString" type="AddressString_t"
minOccurs="0"/>
  </xs:sequence>
</xs:complexType>
<xs:complexType name="EnteredAddress_t">
  <xs:complexContent>
   <xs:restriction base="Address_t">
    <xs:sequence>
     <xs:element name="theAddressString" type="AddressString_t"/>
    </xs:sequence>
   </xs:restriction>
  </xs:complexContent>
</xs:complexType>
<xs:simpleType name="AddressString_t">
  <xs:restriction base="xs:string">
   <xs:maxLength value="50"/>
  </xs:restriction>
</xs:simpleType>
</xs:schema>


Because of the XML Schema Structures recommendation section 
    Schema Component Constraint: Particle Derivation OK (Elt:Elt - NameAndTypeOK) [0] 
        #7  and NOTE

7 R's {type definition} <http://www.w3.org/TR/xmlschema-1/#type_definition>  is validly derived given {extension, list, union} from B's {type definition} <http://www.w3.org/TR/xmlschema-1/#type_definition>  as defined by Type Derivation OK (Complex) (3.4.6) <http://www.w3.org/TR/xmlschema-1/#cos-ct-derived-ok>  or Type Derivation OK (Simple) (3.14.6) <http://www.w3.org/TR/xmlschema-1/#cos-st-derived-ok> , as appropriate. 

NOTE: The above constraint on {type definition} <http://www.w3.org/TR/xmlschema-1/#type_definition>  means that in deriving a type by restriction, any contained type definitions must themselves be explicitly derived by restriction from the corresponding type definitions in the base definition. 


However this runs contrary to both the text in 'Essential XML Quick Reference' on XML Schema xs:restriction (p. 337) and the example in the XML Schema Primer[1] which imply that
simply defining the contained type again in a derived type without the contained type deriving by restriction is allowable. XML Spy also validates both schemas. 

So are we interpreting the recommendation correctly or not?  

[0] http://www.w3.org/TR/xmlschema-1/#rcase-NameAndTypeOK
[1] http://www.w3.org/TR/xmlschema-0/#DerivByRestrict <http://www.w3.org/TR/xmlschema-0/#DerivByRestrict>  

-- 
THINGS TO DO IF I BECOME AN EVIL OVERLORD #110
I will not employ devious schemes that involve the hero's party getting into 
my inner sanctum before the trap is sprung.

 
Received on Friday, 15 March 2002 23:24:04 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:30 GMT