S
Stanimir Stamenkov
I'm trying to find out if it is permissible to include a schema
document with absent target namespace to a schema with specified
target namespace, and if it is, what are the rules to resolve the
target namespace of the components from the included schema document.
I'm confused because of the rules I read in the XML Schema spec
and I've tried using the Xerces2 XSModel implementation with the
following example:
-----"primary-example.xsd"
<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:x-example:test"
xmlns
rimary="urn:x-example:test">
<xs:include schemaLocation="secondary-nonamespace.xsd" />
<xs:element name="doc-root">
<xs:complexType>
<xs:sequence>
<xs:element name="dummy" />
<xs:element ref="primary:test-elem" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
-----"secondary-nonamespace.xsd"
<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="test-elem">
<xs:complexType>
<xs:sequence>
<xs:element name="foo" />
<xs:element name="bar" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
-----
The result is the element components in the included schema are
effectively put in the namespace of the including schema, although
strictly following the rules I've quoted above it shouldn't be
possible, I think.
I guess I'm missing something - could someone point me out?
document with absent target namespace to a schema with specified
target namespace, and if it is, what are the rules to resolve the
target namespace of the components from the included schema document.
I'm confused because of the rules I read in the XML Schema spec
If the <element> element information item has <schema> as its parent, the
corresponding schema component is as follows:
...
{target namespace} The ·actual value· of the targetNamespace [attribute]
of the parent <schema> element information item, or ·absent· if there is none.
...
otherwise if the <element> element information item has <complexType> or
<group> as an ancestor...
...
{target namespace} If form is present and its ·actual value· is qualified,
or if form is absent and the ·actual value· of elementFormDefault on the
<schema> ancestor is qualified, then the ·actual value· of the
targetNamespace [attribute] of the parent <schema> element information item,
or ·absent· if there is none, otherwise ·absent·.
and I've tried using the Xerces2 XSModel implementation with the
following example:
-----"primary-example.xsd"
<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:x-example:test"
xmlns
<xs:include schemaLocation="secondary-nonamespace.xsd" />
<xs:element name="doc-root">
<xs:complexType>
<xs:sequence>
<xs:element name="dummy" />
<xs:element ref="primary:test-elem" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
-----"secondary-nonamespace.xsd"
<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="test-elem">
<xs:complexType>
<xs:sequence>
<xs:element name="foo" />
<xs:element name="bar" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
-----
The result is the element components in the included schema are
effectively put in the namespace of the including schema, although
strictly following the rules I've quoted above it shouldn't be
possible, I think.
I guess I'm missing something - could someone point me out?