472,993 Members | 3,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 software developers and data experts.

[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace

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
<http://www.w3.org/TR/xmlschema-1/#element-element>:
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:primary="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?

--
Stanimir
Jul 20 '05 #1
2 2427
/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 guess I'm missing something - could someone point me out?


O.k. I've found it <http://www.w3.org/TR/xmlschema-1/#src-include>, clause 3.2.

Feeling a bit silly now, but anyway. :-)

--
Stanimir
Jul 20 '05 #2
st****@gbg.bg (Stanimir Stamenkov) writes:
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.


If a schema document gives no target namespace, the normal
rules for processing that document will produce components
without any target namespace, just as you say the relevant
parts of the spec lead you to believe. In other words, your
reading of the part of the spec you quote is quite right.

When such a schema document is INCLUDED, however, special
processing takes place, as described in section 4.2.1 of the
specification [1]: The top level components without
namespaces are treated as orphans, and given a new home in
the namespace of the including document. (This doesn't
strictly speaking contradict the material you quoted,
because it's described not as a change to the mapping from
XML source to schema components, but as an operation
performed on the schema components derived from the
included schema document.)

[1] http://www.w3.org/TR/xmlschema-1/#compound-schema

Components described in a schema document without a target
namespace can thus take on the target namespace of any
including schema document; the phenomenon is known for
obvious reasons as 'chameleon include'.

If that's not what you want -- if you just want those
components, as is, without taking on the coloration of
their surroundings -- then you want to be using import,
not include. An import element in a schema document says
two things: (1) "I'll be referring to components in
another namespace, to wit: ...", and (2) (optionally)
"Some components in that other namespace are over
there; follow the schemaLocation info."

xsd:import imports foreign namespaces; xsd:include includes
new components for the current schema document's target
namespace (and imposes the current target namespace on them
if they don't have one of their own -- if they do have one,
and it's different, then an include should raise an error).

So if by 'include' you mean 'use the xsd:include mechanism',
the answer is no, you cannot do what you describe in XML
Schema 1.0. If by 'include' you just mean 'acquire the
components', then the answer is 'yes, you can, by using
the xsd:import mechanism rather than xsd:include'.

If what you want is not so much a particular behavior as
just to understand what's going on, then you may want to
look at the current working draft of XML Schema 1.1 [2], in
which part (not all, and not enough) of the treatment of
schema composition has been revised to try to make it
clearer. (No change of functionality, just the start of an
attempt to lay it out more clearly.)

[2] http://www.w3.org/TR/xmlschema11-1/

I hope this helps.

-C. M. Sperberg-McQueen
World Wide Web Consortium
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sean Bright | last post by:
Hi there. I'm having a problem which I hope is a simple one... Any help would be appreciated. I think it has something to do with the way attributes are (or are not) inherited in schemas... ...
3
by: Alain Frisch | last post by:
Hello, The following rule in the XML Schema spec, section "Schema Component Constraint: Attribute Wildcard Intersection" seems strange to me: ======================================= 3 If...
8
by: Poonam | last post by:
Hi, Can some one please help me with (or point me to) a very simple but working code sample that shows how to import XML Schema. I have tried many samples out there on internet but nothing seems...
1
by: John Smith | last post by:
Ok, I have 2 xml files that are really similar. They have the exact same structure exept that in one XML some element are required and in the other they are simply absent from the xml. Problem...
2
by: Vagabond Software | last post by:
I have translated a DTD to an XML Schema (XSD) file by hand, and the Schema View in Visual Studio .NET 2003 seems to diplay everything properly. However, when I specify the schemalocation in my...
0
by: Olivier Ishacian | last post by:
XMLmind XML Editor V3.0 Patch 1 can be downloaded from http://www.xmlmind.com/xmleditor/download.shtml _____________________________________________ V3.0 Patch 1 (December 2, 2005) ...
0
by: liuhengyi | last post by:
Hi, I also have a question when using VS 2008 to edit the xml file. In my xml file, I used schemaLocation attribute to specify the xsd. If I put the xsd in our internal sharepoint site such as:...
4
by: Tony Johansson | last post by:
Hello! I know this might not be the appropriate forum for xml question. But xml is so important for .NET I hope my basic question can be answered in this forum. I just wonder does every xml...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.