473,903 Members | 4,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

targetNamespace/import conflict



I've been asked to look over an integration toolkit that has a bunch
of schemas to specify message format. There are a couple of strange
things I noticed right off the bat and I wanted to get others'
thoughts on it (disclaimer, obviously I'm no XML expert so forgive me if
these are basic).

--------Exhibit A: The start of a response message schema-----------
<xsd:schema targetNamespace ="http://www.QQQ.com"
xmlns:QQQ="http ://www.QQQ.com/datatypes"
xmlns="http://www.QQQ.com"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
elementFormDefa ult="unqualifie d">

<xsd:import namespace="http ://www.QQQ.com/datatypes"
schemaLocation= "../general/datatypes.xsd"/>

<xsd:import namespace="http ://www.QQQ.com"
schemaLocation= "../general/datatypes.xsd"/>
--------Exhibit B: The start of general/datatypes.xsd --------------

<xsd:schema targetNamespace ="http://www.QQQ.com/datatypes"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns="http://www.QQQ.com/datatypes"
elementFormDefa ult="unqualifie d"
attributeFormDe fault="unqualif ied">

--------------------------------------------------------------------

#1) Exhibit A seems to be following poor form by using such a generic
targetNamespace (the same one is used for all their top-level schema).
The convention I've seen is that the targetNamespace should be the
public URL of the document.

#2) Exhibit A defines both the default and QQQ namespace to point to
the same schema (namely, Exhibit B). I guess I don't have a problem
with it technically (sans #3) but it does seem bizarre. Seems like a
really bad idea in fact. Would you do this so you could normally refer
to a name X without qualification unless there were some ambiguity with
an X in the current document (and so you could refer to it as QQQ:X)?

#3) The namespace used in the 2nd import of Exhibit A does not match the
targetNamespace of Exhibit B. Why would someone do this?

#4) Please confirm/dispute my interpretation of the elementForDefau lt
and the attributeFormDe fault: all these say is that I do not have to qualify
elements in the document but they are still implicitly part of the
default namespace for that document (and hence would be subject to the
appropriate validations).

If this is all just bad form, so be it (and I may have a chance to
get it fixed) but if there are plausible reasons for why one would
do things this way I sure would like to hear about them.

Thanks,

Charlie Fineman

Jul 20 '05 #1
2 10040
Charles Fineman <cf************ **@yahoo.com> writes:
--------Exhibit A: The start of a response message schema-----------

<xsd:schema targetNamespace ="http://www.QQQ.com"
xmlns:QQQ="http ://www.QQQ.com/datatypes"
xmlns="http://www.QQQ.com"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
elementFormDefa ult="unqualifie d">

<xsd:import namespace="http ://www.QQQ.com/datatypes"
schemaLocation= "../general/datatypes.xsd"/>

<xsd:import namespace="http ://www.QQQ.com"
schemaLocation= "../general/datatypes.xsd"/>
--------Exhibit B: The start of general/datatypes.xsd --------------

<xsd:schema targetNamespace ="http://www.QQQ.com/datatypes"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns="http://www.QQQ.com/datatypes"
elementFormDefa ult="unqualifie d"
attributeFormDe fault="unqualif ied">

--------------------------------------------------------------------

#1) Exhibit A seems to be following poor form by using such a generic
targetNamespace (the same one is used for all their top-level schema).
The convention I've seen is that the targetNamespace should be the
public URL of the document.
Odd, perhaps, but it doesn't seem likely to make anything harder, now
or later. On the question of whether a namespace name should be
dereferenceable , large numbers of electrons have been spilt; suffice
to say that both sides of the question can be argued, and are.
#2) Exhibit A defines both the default and QQQ namespace to point to
the same schema (namely, Exhibit B).
Well, not as you have shown it. Exhibit A and Exhibit B each define
their target namespace as their default namespace. Exhibit A binds
the prefix 'QQQ' to the URL "http://www.QQQ.com/datatypes", not to the
default namespace (which is "http://www.QQQ.com").

And (pedantry alert) Exhibit B is, I assume, a document available via
some URI. A namespace is an abstraction named by a URI, and should
not be confused with a document.
#3) The namespace used in the 2nd import of Exhibit A does not match
the targetNamespace of Exhibit B. Why would someone do this?
Good question.

Perhaps they want to test the conformance of the schema processor: as
far as I can tell, the second import statement violates constraint
src-import.1.1 (" If the namespace [attribute] is present [on the
import element], then its actual value must not match the actual value
of the enclosing <schema>'s targetNamespace [attribute]").

As it happens, Xerces J agrees with me: its error message is

[Error] a.xsd:11:38: src-import.1.1: The namespace attribute
'http://www.QQQ.com' of an <import> element information item
must not be the same as the targetNamespace of the schema it
exists in.

To my surprise, XSV doesn't seem to catch this problem and
accepts the schema documents.
#4) Please confirm/dispute my interpretation of the
elementForDefau lt and the attributeFormDe fault: all these say is
that I do not have to qualify elements in the document but they are
still implicitly part of the default namespace for that document
(and hence would be subject to the appropriate validations).


Well, I think you're close but I'm not sure I understand exactly what
you mean.

If the elementFormDefa ult and attributeFormDe fault attributes are both
set to "unqualifie d", it means that local elements and local
attributes are defined without any namespace affiliation. They will
be referred to in a document instance by unqualified names
(i.e. unprefixed names in an environment without a default namespace),
and occurrences of them in the document instance in the relevant
contexts will be validated against the relevant declarations or
definitions in the schema -- so far, I think this is what you mean by
"I do not have to qualify elements in the document" and by being
"subject to the appropriate validations".

But they are not implicitly, explicitly, or in any other way "in", or
"part of", the target namespace of the schema document. (Or, to be
painfully precise, such a conclusion is not licensed by either the
namespaces Rec or the XML Schema spec.) Their only link to the target
namespace is that they are declared as local to a type defined in the
target namespace.

I hope this helps.

-C. M. Sperberg-McQueen

Jul 20 '05 #2
Thanks for the response... only just now noticed it :-)

C. M. Sperberg-McQueen wrote:
Charles Fineman <cf************ **@yahoo.com> writes:

--------Exhibit A: The start of a response message schema-----------

<xsd:schema targetNamespace ="http://www.QQQ.com"
xmlns:QQQ="http ://www.QQQ.com/datatypes"
xmlns="http://www.QQQ.com"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
elementFormDefa ult="unqualifie d">

<xsd:import namespace="http ://www.QQQ.com/datatypes"
schemaLocation= "../general/datatypes.xsd"/>

<xsd:import namespace="http ://www.QQQ.com"
schemaLocation= "../general/datatypes.xsd"/>
--------Exhibit B: The start of general/datatypes.xsd --------------

<xsd:schema targetNamespace ="http://www.QQQ.com/datatypes"
xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns="http://www.QQQ.com/datatypes"
elementFormDefa ult="unqualifie d"
attributeFormDe fault="unqualif ied">

--------------------------------------------------------------------
#2) Exhibit A defines both the default and QQQ namespace to point to
the same schema (namely, Exhibit B).

Well, not as you have shown it. Exhibit A and Exhibit B each define
their target namespace as their default namespace. Exhibit A binds
the prefix 'QQQ' to the URL "http://www.QQQ.com/datatypes", not to the
default namespace (which is "http://www.QQQ.com").

And (pedantry alert) Exhibit B is, I assume, a document available via
some URI. A namespace is an abstraction named by a URI, and should
not be confused with a document.


Ah but this was the source of my confusion. In this case, they specify
that the document in exhibit B as the definition of both the default and
QQQ namespace. I just don't see the value in doing this.

#4) Please confirm/dispute my interpretation of the
elementForDef ault and the attributeFormDe fault: all these say is
that I do not have to qualify elements in the document but they are
still implicitly part of the default namespace for that document
(and hence would be subject to the appropriate validations).

Well, I think you're close but I'm not sure I understand exactly what
you mean.

If the elementFormDefa ult and attributeFormDe fault attributes are both
set to "unqualifie d", it means that local elements and local
attributes are defined without any namespace affiliation. They will
be referred to in a document instance by unqualified names
(i.e. unprefixed names in an environment without a default namespace),
and occurrences of them in the document instance in the relevant
contexts will be validated against the relevant declarations or
definitions in the schema -- so far, I think this is what you mean by
"I do not have to qualify elements in the document" and by being
"subject to the appropriate validations".

But they are not implicitly, explicitly, or in any other way "in", or
"part of", the target namespace of the schema document. (Or, to be
painfully precise, such a conclusion is not licensed by either the
namespaces Rec or the XML Schema spec.) Their only link to the target
namespace is that they are declared as local to a type defined in the
target namespace.


Thanks... the distinction is clear and makes sense. I have questions
about ambiguity rolling around in my head though... what happens in
complex types when sub-elements come from different name spaces. For
example, can we ever run into problems with things like:

<a:A>
<b:B>
<c:C>
<value> ... </value>
</c:C>
</b:B>
</a:A>

If value is declared in multiple namespaces?

Thanks again for the response.

Jul 20 '05 #3

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

Similar topics

9
2950
by: Paul Rubin | last post by:
That's what the Python style guides advise. They don't seem to like def frob(x): import re if re.search('sdfxyz', x): ... instead preferring that you pollute your module's global namespace with the names of all your imports. What's the point of that? It gets worse when you want to do something like
1
18393
by: kevin bailey | last post by:
hi there, i'm reading up on schema - but am probably missing something obvious RE targetnamespace i know there can only be one... is it that the elements which are defined in the schema which have no prefix are somehow now part of the namespace - would it need to upload the definitions?
0
1238
by: comic_rage | last post by:
Hi, I am trying to add the targetNamespace with the xmlns to my xml schema file, but I am getting the following <?xml version="1.0" encoding="utf-8"?> <xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.ciber.com/myfile" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
1
1349
by: Maansi Sanghi | last post by:
Hello, I am trying to write an xsd file using .NET System.Xml.Sxhema Class Library. (1) I get an error while writitng if the XSD has a taregetnamespace. (II) for any xsd with no targetnamespace the program works fine. I want to create an xsd with the following namespaces <xsd:schema targetNamespace"http://www.homedepot.com/HD"
5
5409
by: Jeff | last post by:
We are using .Net and the wsdl Utility to generate proxies to consume web services built using the BEA toolset. The data architects on the BEA side create XML schemas with various entities in separate files for ease of maintainability. These schemas are all part of the same namespace. When defining a web service that access more than one of these entities, the wsdl file generated by BEA contains multiple schema elements with the same...
11
1862
by: Connelly Barnes | last post by:
Hi, I wrote the 'autoimp' module , which allows you to import lazy modules: from autoimp import * (Import lazy wrapper objects around all modules; "lazy modules" will turn into normal modules when an attribute is first accessed with getattr()). from autoimp import A, B (Import specific lazy module wrapper objects). The main point of autoimp is to make usage of the interactive Python prompt
3
1655
by: rplzqx402 | last post by:
Hello, I have a problem where I need to set up two separate Python projects that each live under the same package. Once they are distributed, they will live under the same filesystem path, but during development, they are separated. For example: proj1/lib/pkg/foo/mod1.py proj2/lib/pkg/bar/mod2.py
10
1431
by: iu2 | last post by:
Hi all I've got three files: file a1.py: ======== the_number = None file a2.py: ========
5
5220
by: Stef Mientki | last post by:
hello, The import statement "import sqlite3" gives the error given below. In simple programs, the import statement (sometimes) succeed, and I can indeed access the database. So I guess there is some conflict with another part of my program, but as the program is rather large (and dynamic) it's not easy to isolate the problem. Does anyone has a clue how to trace this kind of problem ?
0
11291
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10882
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10988
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9692
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5897
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6099
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4312
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.