RE: Feature incompatiblity in XML Schema 1.0

Welcome to the club - better late than never.  Of course, one of the points
of the original NUN proposal was that the prefix to the local name was the
namespace.   Also, nested definitions allow us to get rid of anonymous types
and allow much better control of restriction/extension.  It would be good to
discuss this issue _before_ we decide on a SCD syntax, as it allows a
cleaner syntax where a name is always 0 or more type names followed by 0 or
1 element or attribute name.  For example:

<xs:schema targetNamespace="schema1">
  <xs:complexType name="foo">
     <xs:complexType name="bar">
       <xs:sequence>
          <xs:element name="x" type="xs:int" minOccurs="0"/>
          <xs:element name="y" type="xs:int" maxOccurs="10"/>
       </xs:sequence>
     </xs:complexType>
     <xs:element name="locFoo" type="bar"/>
     <xs:sequence>
       <xs:element ref="locFoo"/>
       <xs:element name="z" type="xs:int" minOccurs="0"/>
     </xs:sequence>
  </xs:complexType>
  <xs:element name="foo" type="foo"/>
  <xs:complexType name="restrictFoo">
     <xs:complexContent>
        <xs:restriction base="foo" xs:foo="namespace of local foo above">
           <xs:complexType name="restrictBar">
              <xs:complexContent>
                 <xs:restriction base="foo:bar">
                    <xs:sequence>
                       <xs:element ref="foo:y" maxOccurs="5"/>
                    </xs:sequence>
                 </xs:restriction>
              </xs:complexContent>
           </xs:complexType>
           <xs:element name="locFoo" type="restrictBar"
substitutionGroup="foo:locFoo"/>
           <xs:sequence>
              <xs:element ref="locFoo"/>
           </xs:sequence>
        </xs:restriction>
     </xs:complexContent>
   </xs:complexType>
</xs:schema>

Note that all elements are reached through a trail of complexTypes, so
complexTypes can be treated as namespaces - the current alternation syntax
makes that very muddy.  This also allows us to treat namespaces as coming in
two flavors - ordered and unordered.  The example of an unordered namespace
is a schema, and complexTypes are the ordered ones.  Which is to say that
all namespaces are of a nested structure containing element and attribute
names.

But if a local element is in the namespace of its complexType, given your
syntax below, then surely as a logical consequence:

<a:BE xmlns:a="urn:a:aaa"
xmlns:base="a.xsd#xsucd(ct::a:Base)"><base:x>1</base:x><base:y>2</base:y></a
:BE>

is valid because it puts x and y in their actual namespace and:

<a:BE xmlns:a="urn:a:aaa"><a:x>a</a:x><a:y>2</a:y></a:BE>

is not because it doesn't.

Note that if we make the change that puts local elements in the namespace of
their enclosing type - as is being suggested - then a definition that had
local elements unqualified, eg:

  <xs:complexType name="Base" >
    <xs:sequence>
      <xs:element name="x" type="xs:int"/>
      <xs:element name="y" type="xs:int" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>

which would be the current version of your complexType would have an
instance looking like:

<a:BE xmlns:a="urn:a:aaa"><x>1</x><y>2</y></a:BE>

which could be brought up to snuff by injecting some xmlns default
attributes:

<a:BE xmlns="a.xsd#xsucd(ct::a:Base)"><x>1</x><y>2</y></a:BE>

which could be easily accomplished with a perl script and wreak much less
havoc on existing applications than would be the case for a schema with
qualified attributes.

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

The one change being considered for version 1.1 which would make this
work no matter what, without requiring the intervening stub, is the
move from local declaration within content models to local declaration
within types.  Combined with UCDs, this would allow something like
this:

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:element name="x" type="xs:int" form="qualified" />
      <xs:element name="y" type="xs:int" form="qualified"/>
    <xs:sequence>
      <xs:element ref="x" />
      <xs:element ref="y" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
  <xs:element name="BE" type="a:Base" />
</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="a.xsd"/>
  <xs:complexType name="Derived">
    <xs:complexContent>
      <xs:restriction base="a:Base"
                      xmlns:aBase="a.xsd#xsucd(ct::a:Base)">
        <xs:sequence>
          <xs:element ref="aBase:x" />
          <xs:element name="aBase:y" minOccurs="1" />
        </xs:sequence>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>

I actually rather like the idea of treating complex type definitions
as namespaces within which the names of their local element
declarations sit.

ht
[1]
http://lists.w3.org/Archives/Public/www-xml-schema-comments/2002OctDec/0087.
html
--
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2002, 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/
 [mail really from me _always_ has this .sig -- mail without it is forged
spam]

Received on Thursday, 5 December 2002 13:20:16 UTC