W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > October to December 2002

RE: Feature incompatiblity in XML Schema 1.0

From: Matthew Fuchs <matt@westbridgetech.com>
Date: Thu, 5 Dec 2002 09:17:22 -0800
To: "Henry S. Thompson" <ht@cogsci.ed.ac.uk>, "Don Box" <dbox@microsoft.com>
Cc: <www-xml-schema-comments@w3.org>, "Ashok Malhotra" <ashokma@microsoft.com>, "Martin Gudgin" <mgudgin@microsoft.com>, "Allen Brown" <allenbr@microsoft.com>
Message-ID: <MNELKPFAIFJKHNJLJDOIMEHKCPAA.matt@westbridgetech.com>

Henry,

I believe this is (or ought to be) illegal because the restriction may allow
content not legal in the parent.  However, if it is legal, you win the grand
prize - an example where static type checking, as I've defined it elsewhere,
is broken.  Note my insertions below.

Matthew

-----Original Message-----
From: www-xml-schema-comments-request@w3.org
[mailto:www-xml-schema-comments-request@w3.org]On Behalf Of Henry S.
Thompson
Sent: Thursday, December 05, 2002 1:52 AM
To: Don Box
Cc: www-xml-schema-comments@w3.org; Ashok Malhotra; Martin Gudgin; Allen
Brown
Subject: Re: Feature incompatiblity in XML Schema 1.0



You analysis is correct, but I don't understand the implicit
evaluative component of your message - why is this a problem that
needs to be fixed?  By making a declaration both local and qualified,
the author has essentially staked a permanent claim on the association
between those qualifided names and their types in that context.  You can
override this, but to do so you have to usurp the author's namespace
explicitly, either using <redefine>, or as follows:

a.xsd:
<xs:schema targetNamespace="urn:a:aaa"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:a="urn:a:aaa" >
  <xs:complexType name="Base" >
    <xs:sequence>
      <xs:element name="x" type="xs:int" form="qualified" />
      <xs:element name="y" type="xs:int" minOccurs="0" form="qualified"/>
    </xs:sequence>
  </xs:complexType>
  <xs:element name="BE" type="a:Base" />
</xs:schema>

aprime.xsd:
<xs:schema targetNamespace="urn:a:aaa"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:a="urn:a:aaa" >
 <xs:include schemaLocation="a.xsd"/>
 <xs:element name="y" type="xs:int"/>
 <xs:element name="x" type="xs:int"/>
</xs:schema>

<xs:schema targetNamespace="urn:b:bbb"
  xmlns:a="urn:a:aaa"
  xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xs:import namespace="urn:a:aaa" schemaLocation="aprime.xsd"/>
  <!-- MDF - note use of substitution groups -->
  <xs:element name="y-prime" type="xs:int" substitutionGroup="a:y"/>
  <xs:element name="x-prime" type="xs:int" substitutionGroup="a:x"/>
  <!-- MDF -->
  <xs:complexType name="Derived">
    <xs:complexContent>
      <xs:restriction base="a:Base" >
        <xs:sequence>
          <xs:element ref="a:x" />
          <xs:element ref="a:y" minOccurs="1" />
        </xs:sequence>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>

As long as the local element decls you want to appropriate don't have
anonymous type definitions, such a move is always possible.

MDF>  Because of the presence of substitution groups, the restriction would
allow

<a:BE
xsi:type="b:Derived"><b:x-prime>0</b:x-prime><b:y-prime>1</b:y-prime></a:BE>

which clearly is not valid for <a:BE>.  Once again, very nasty non-local
effects become possible - the element subtypes could be in a third schema
completely.  It's also very nasty for implementation - since there could be
any number of layers, restrictions with qualified elements would need to be
matched against all the ancestor types, not just the most local one - I'll
be no one does this.  Therefore, if this is not illegal, it should be made
so.

Matthew
Received on Thursday, 5 December 2002 12:17:57 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 18:13:01 GMT