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

Including schemas with no targetnamespace

From: Jeff Lowery <jlowery@scenicsoft.com>
Date: Mon, 15 Oct 2001 10:15:37 -0700
Message-ID: <3549BAFD79A7D411A1CF00508B62B5BC3D10E3@exchange-us.scenicsoft.com>
To: xmlschema-dev@w3.org
Cc: ht@cogsci.ed.ac.uk
I've read the spec, but I'm still confused regarding this one case (it
doesn't help that schema checkers don't agree, either):

Say I have the following schema, no target namespace declared:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns=""> 

  <xsd:element name="color" type="xsd:string"/>
    
  <xsd:element name="fruit">
     <xsd:complexType>
        <xsd:sequence>
           <xsd:element ref="color"/> 
        </xsd:sequence>
     </xsd:complexType>
  </xsd:element> 
</xsd:schema>


Now, this gets included in a schema with a target namespace:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema 
 targetNamespace="http://www.example.com/fruitbasket"
 xmlns:fb="http://www.example.com/fruitbasket" 
 xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
	<xs:include schemaLocation="fruit.xsd"/>

	<xs:element name="fruitbasket">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="fb:fruit"
maxOccurs="unbounded"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>

Now, I know that through inclusion, the fruit schema acquires the
targetnamespace of the fruitbasket schema, hence the fb prefix on the fruit
reference in the fruitbasket type definition. 

The color element in the fruit schema was also declared globally, so it,
too, should acquire the target namespace of the schema that includes its
schema. But the reference to color in fruit is not prefixed, which, without
a default namespace declared, I would expect to be interpreted as referring
to a color name with no namespace.

Both XSV and SQC validate both schemas; XML Spy interprets color as an
invalid reference when the fruit schema is included in the fruitbasket
schema. 

I read 4.2.1 of Structures, but I must confess that I'm still unclear as to
whether it covers this particular case. Spy's interpretation seems the most
consistent, unless the parser is allowed to "repair" the references in
included schemas with no target or default namespace.
Received on Monday, 15 October 2001 13:16:10 GMT

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