Including schemas with no targetnamespace

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 UTC