- From: Roger L. Costello <costello@mitre.org>
- Date: Sat, 24 Feb 2001 06:33:31 -0500
- To: xmlschema-dev@w3.org, costello@mitre.org
Hi Folks,
XSV is generating an error when a no-namespace schema (containing
components that reference one another) is <include>d into a schema with
a targetNamespace.
Consider this no-namespace schema:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
        elementFormDefault="qualified">
    <xsd:complexType name="CardCatalogueEntry">
        <xsd:sequence>
            <xsd:element name="Title" type="xsd:string"/>
            <xsd:element name="Author" type="xsd:string"/>
            <xsd:element name="Date" type="xsd:string"/>
            <xsd:element name="ISBN" type="xsd:string"/>
            <xsd:element name="Publisher" type="xsd:string" />
        </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="Book" type="CardCatalogueEntry"/>
</xsd:schema>
This schema has two components - a complexType CardCatalogueEntry
component and an element Book component.  The Book component references
the CardCatalogueEntry component. 
Consider what happens when these components are included in a schema
with a namespace.  
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
        targetNamespace="http://www.library.org"
        xmlns="http://www.library.org"
        elementFormDefault="qualified">
    <xsd:include schemaLocation="BookCatalogue.xsd"/>
    <xsd:element name="Library">
        <xsd:complexType>
             <xsd:sequence>
                 <xsd:element name="BookCatalogue">
                     <xsd:complexType>
                         <xsd:sequence>
                             <xsd:element ref="Book"/>
                         </xsd:sequence>
                     </xsd:complexType>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>
Note that the targetNamespace is the default namespace.  When the
no-namespace components (Book and CardCatalogueEntry) are included in
this schema they take on the targetNamespace.  Consequently, this
element declaration in the no-namespace schema:
    <xsd:element name="Book" type="CardCatalogueEntry"/>
should be referencing a CardCatalogueEntry component in the
targetNamespace. [Or, is Book still referencing CardCatalogueEntry in
no-namespace?  Do only the components take on the namespace of the
<include>ing schema, or do the references also take on the namespace?  I
am not clear on this.]  
When I ran this example in XSV I got this error message:
Undefined type {None}:CardCatalogueEntry referenced as type definition
of Book
This would seem to suggest that:
    <xsd:element name="Book" type="CardCatalogueEntry"/>
is still referencing the CardCatalogueEntry in no-namespace (as opposed
to a reference to CardCatalogueEntry in the default namespace).
There are two possibilities:
{1} XSV has a bug and type="CardCatalogueEntry" is a reference to the
CardCatalogueEntry in the default namespace (which in my schema is the
targetNamespace)
{2} There is no bug in XSV and type="CardCatalogueEntry" is a reference
to the CardCatalogueEntry in no-namespace, and XSV's error message is
valid.
Can you please enlighten me as to the true nature of <include>ing
coupled no-namespace components - when no-namespace components are
<include>d in a schema do the no-namespace component references become
references to the <include>ing schema's default namespace, or do they
continue as references to no-namespace? /Roger
Received on Saturday, 24 February 2001 06:32:18 UTC