 |
 |
 |
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
|
 | 

|  |
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.
|  |
| |
 |
 |
 |