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

Unqualified type names in Schema documents without targetNamespace

From: Bob Schloss <rschloss@us.ibm.com>
Date: Tue, 20 Mar 2001 17:50:52 -0500
To: xmlschema-dev@w3.org
Message-ID: <OF28C630CB.65E6ECC4-ON85256A15.007A7B50@pok.ibm.com>

How many namespaces can dance on the head of a pin? :-)

The primer, section 3.4 says:
In cases where a schema is designed without a target namespace, it is
strongly recommended that all Schema elements and types are explicitly
qualified with a prefix such as xsd: that is associated with the XML Schema
namespace (as in po.xsd). The rationale for this recommendation is that if
Schema elements and types are associated with the XML Schema namespace by
default, i.e. without prefixes, then references to XML Schema types may not
be distinguishable from references to user-defined types.

This could be said even stronger: Do not associate
http://www.w3.org/2001/XMLSchema with the lack of a prefix.

I just had to explain to someone (who is not naive about namespaces, BTW)
these three cases:

First, a schema where I think processors would say "There is no type called
http://www.w3.org/2001/XMLSchema:USAddress" and "There is no type called
http://www.w3.org/2001/XMLSchema:PurchaseOrderType".

<schema xmlns="http://www.w3.org/2001/XMLSchema"
>arch.ibm.com/Sketch/InvalidSchemas">
  <element name="purchaseOrder" type="PurchaseOrderType"/>
  <complexType name="PurchaseOrderType">
    <sequence>
      <element name="shipTo" type="USAddress"/>
    </sequence>
  </complexType>
  <complexType name="USAddress">
    <sequence>
      <element name="name"   type="string"/>
    </sequence>
  </complexType>
</schema>

Second is a schema that improperly confuses a URI of '' with no URI:

<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:a=''>
  <element name="purchaseOrder" type="a:PurchaseOrderType"/>
  <complexType name="PurchaseOrderType">
    <sequence>
      <element name="shipTo" type="a:USAddress"/>
    </sequence>
  </complexType>
  <complexType name="USAddress">
    <sequence>
      <element name="name"   type="string"/>
    </sequence>
  </complexType>
</schema>



XSV says:
attribute type check failed for {None}:type: a:PurchaseOrderType has
undeclared prefix: a

Undeclared?

Structures section 3.15.2 says
Since the empty string is a legal (relative) URI reference, supplying an
empty string for targetNamespace is not the same as not specifying it at
all.

This makes me think that my second schema does not refer to its own
complexType USAddress,



Third is a schema which I think is legal:

<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:a='' targetNamespace
=''>
  <element name="purchaseOrder" type="a:PurchaseOrderType"/>
  <complexType name="PurchaseOrderType">
    <sequence>
      <element name="shipTo" type="a:USAddress"/>
    </sequence>
  </complexType>
  <complexType name="USAddress">
    <sequence>
      <element name="name"   type="string"/>
    </sequence>
  </complexType>
</schema>

XSV says:
attribute type check failed for {None}:type: a:PurchaseOrderType has
undeclared prefix: a

I don't understand why it does this.

I think the problem is that to be clear about how namespaces can be used in
W3C XML Schemas, you need to
very carefully read Structures and Primer.


Bob
Received on Tuesday, 20 March 2001 17:50:56 GMT

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