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

Re: CR Feedback and Implementation

From: C. M. Sperberg-McQueen <cmsmcq@acm.org>
Date: Wed, 27 Dec 2000 10:53:59 -0700
Message-Id: <4.3.2.7.1.20001227103422.028f07c0@espanola.com>
To: ht@cogsci.ed.ac.uk (Henry S. Thompson)
Cc: "Falk, Alexander" <al@altova.com>, www-xml-schema-comments@w3.org
At 2000-12-18 07:23, Henry S. Thompson wrote:
 > "Falk, Alexander" <al@altova.com> writes:

 >> 1) the CR should perhaps expressedly inform the reader, that any
 >> schema document that uses a default namespace (ie no prefix) to
 >> refer to "http://www.w3.org/2000/10/XMLSchema" must have a
 >> targetNamespace - otherwise any type="..." or ref="..." can not be
 >> correctly attributed to either the built-in types of XML schema or
 >> the types that the user defines in his/her schema

 > I'm not sure I understand.  The following is perfectly valid:

 > <schema xmlns="http://www.w3.org/2000/10/XMLSchema">
 >  <element name="foo">
 >   <sequence>
 >    <element name="bar" type="integer"/>
 >    <element name="baz" type="date"/>
 >   </sequence>
 >  </element>
 > </schema>

Well, actually it's not.  The 'sequence' element is not allowed there,
you have to wrap it in a complexType element.

But consider the case where the schema author actually wants to
refer to other things in the schema.

    <schema
      xmlns     = "http://www.w3.org/2000/10/XMLSchema"
      elementFormDefault="qualified"
      >
      <annotation>
        <documentation>
          This is a sample schema to demonstrate using the XML Schema
          namespace as the default namespace for a schema without a
          target namespace.
        </documentation>
      </annotation>

      <annotation>
        <documentation>This declaration is fine.</documentation>
      </annotation>

      <complexType name="tA">
        <sequence><element type="integer" name="i"/></sequence>
      </complexType>


      <annotation>
        <documentation>
          These declarations, on the other hand, are unlikely to be
          what any schema author will have in mind.

          Complex types tB and tC won't be successful in saying what
          types they are derived from.
        </documentation>
      </annotation>

      <complexType name="tB">
        <complexContent>
          <extension base="tA">
    	<sequence><element type="integer" name="j"/></sequence>
          </extension>
        </complexContent>
      </complexType>

      <complexType name="tC">
        <complexContent>
          <extension base="tB">
    	<sequence><element type="integer" name="k"/></sequence>
          </extension>
        </complexContent>
      </complexType>

      <annotation>
        <documentation>
          Element type 'ace' will have trouble making clear which
          elements are supposed to be its children.
        </documentation>
      </annotation>

      <element name="ace">
        <complexType>
          <choice maxOccurs="unbounded" minOccurs="0">
    	<element ref="A"/>
    	<element ref="B"/>
    	<element ref="C"/>
    	<element ref="X"/>
          </choice>
        </complexType>
      </element>

      <annotation>
        <documentation>
          Element types A, B, C, and X will have trouble saying
          what type they have.
        </documentation>
      </annotation>

      <element type="tA" name="A"/>
      <element type="tB" name="B"/>
      <element type="tC" name="C"/>
      <element type="tA" name="X"/>

    </schema>

This is legal, but not useful.  The schema I use (i.e. the schema
provided by our spec) for the XML Schema namespace does not declare
complex types named tA, tB, or tC, nor elements named A, B, C, or X.
So a document which tries to use this schema won't be able to use
anything declared here.

It's true that on some occasions one might successfully use the XML
Schema namespace as the default namespace in a schema document without
a target namespace, as illustrated by Henry's example.  But precisely
because my example schema document is not illegal and won't by itself
raise any error messages, I think a casual warning (a bit weaker than
suggested by Alexander Falk) is probably a good idea: "Note that if
the XML Schema namespace is used as the default namespace, the schema
document itself should almost always have an explicit target
namespace.  Otherwise, it will be impossible to refer to anything declared
in the schema from elsewhere in the schema."  Perhaps the warning belongs
in the Primer, rather than the Structures spec.

C. M. Sperberg-McQueen
Received on Wednesday, 27 December 2000 14:01:56 GMT

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