473,287 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 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 2453
/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: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.