W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2004

Chaining <xs:import> statements

From: Delmerico, James <James.Delmerico@ips-sendero.com>
Date: Tue, 22 Jun 2004 09:11:54 -0700
Message-ID: <4F043329520A7A4D997C792418D9E552025E8D7A@osgood.ips-sendero.com>
To: xmlschema-dev@w3.org
I have a situation where my schema imports a schema (parent) which, in turn,
imports another schema (child).  I am referencing elements from both schemas
in my schema but only importing the (parent) schema while declaring both
namespaces in my schema.

 

What I have found is the .NET implementation of XML Schema complains about
this with the following warning:

 

"Namespace 'baseURI' is not available to be referenced in this schema."

 

The schema still properly validates the document even items coming from the
(child) schema, but the warning concerns me.  If I <import> the (child) in
my schema the warning goes away, but this also seems incorrect - would I not
be importing the schema twice (implementation issues aside)?

 

What should be correct way to handle this situation?

 

Here is a simple contrived example that demonstrates the issue:

 

Base.xsd

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="baseURI"      >

            <xs:complexType name="baseType">

                        <xs:sequence    >

                                    <xs:element name="name"
type="xs:string"/>

                                    <xs:element name="age" type="xs:int" />

                        </xs:sequence   >          

            </xs:complexType>

</xs:schema>

 

Composite.xsd

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="compositeURI"


 xmlns:b="baseURI">

<xs:import schemaLocation="base.xsd" namespace="baseURI"/> 

            <xs:complexType name="composite">

                                    <xs:sequence maxOccurs="unbounded"  >

                                                <xs:element name="person"
type="b:baseType" />

                                                <xs:element name="reference"
type="b:baseType" />

                                    </xs:sequence> 

            </xs:complexType>       

</xs:schema>

 

Interview.xsd

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:b="baseURI"
xmlns:c="compositeURI">

            <xs:import namespace="compositeURI"
schemaLocation="composite.xsd"            />

            <!-- warning unless uncommented -->

            <!-- xs:import namespace="baseURI" schemaLocation="base.xsd"
/ -->

            <xs:element name="root" type="people"  />

            <xs:complexType name="people">

                        <xs:sequence maxOccurs="10">

                            <xs:element name="interviewer" type="b:baseType"
/>

                                    <xs:element name="candidate"
type="c:composite" />

                        </xs:sequence>

            </xs:complexType>       

</xs:schema>

 

Instance.xml

<?xml version="1.0" encoding="UTF-8"?>

<!--Sample XML file generated by XMLSPY v2004 rel. 4 U
(http://www.xmlspy.com)-->

<root xmlns:b="baseURI" xmlns:c="compositeURI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="interview.xsd">

            <interviewer>

                        <b:name>Hal</b:name>

                        <b:age>36</b:age>        

            </interviewer>

            <candidate>

                        <c:person>

                                    <b:name>Dave</b:name>           

                                    <b:age>45</b:age>        

                        </c:person>

                        <c:reference>

                                    <b:name>Frank</b:name>         

                                    <b:age>51</b:age>        

                        </c:reference>

            </candidate>

</root>

 

Thanks!

 

James Delmerico

Senior Technical Architect, IPS-Sendero

(770) 409-0047 x437

230 Scientific Dr, Suite 800

Norcross, GA  30092

 
Received on Tuesday, 22 June 2004 12:13:16 GMT

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