473,408 Members | 2,832 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,408 software developers and data experts.

2 namespaces in 1 schema

Hi,
Can I have 2 namespaces in the same XML schema?
In the schema, I wish to declare elements such that some of them
belong to one namespace and others belong to a second namespace. Is
this possible? Note that both the namespaces should be in the same
schema and same xsd file. Could somebody provide a small snippet on
how to do this?

Thanks for your time.
Jul 20 '05 #1
5 2215


Zombie wrote:

Can I have 2 namespaces in the same XML schema?


You need at least one schema to define elements for each namespace but
of course a schema for one namespace can import a schema for another
namespace and then reference elements from the other namespace.


--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
Martin Honnen <ma*******@yahoo.de> wrote in message news:<41**********************@newsread2.arcor-online.net>...
Zombie wrote:

Can I have 2 namespaces in the same XML schema?


You need at least one schema to define elements for each namespace but
of course a schema for one namespace can import a schema for another
namespace and then reference elements from the other namespace.


Do you mean to say that 1 schema file can contain only 1 namespace?
Actually, 'import' is exactly what I want to avoid. That is why in the
OP, I explicitly mentioned that I want 1 schema in 1 xsd file
containing 2 namespaces.
Any way to do that?

Thanks much.
Jul 20 '05 #3
Zombie wrote:
Martin Honnen <ma*******@yahoo.de> wrote in message news:<41**********************@newsread2.arcor-online.net>...
Zombie wrote:
Can I have 2 namespaces in the same XML schema?


You need at least one schema to define elements for each namespace but
of course a schema for one namespace can import a schema for another
namespace and then reference elements from the other namespace.

Do you mean to say that 1 schema file can contain only 1 namespace?
Actually, 'import' is exactly what I want to avoid. That is why in the
OP, I explicitly mentioned that I want 1 schema in 1 xsd file
containing 2 namespaces.
Any way to do that?


Does this help ?

(This is an example given to me by Zafar Abbas at the newsgroup
microsoft.public.xml. Google for "Schema - Definition for checking part of
schema?")

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="a">
<xs:complexType>
<xs:sequence>
<xs:group ref = "allowAny"/>
<xs:element name="aa" />
<xs:group ref = "allowAny"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:group name="allowAny">
<xs:sequence>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other" />
</xs:sequence>
</xs:group>

</xs:schema>

The following xml will be valid according to it:

<a xmlns:ns="ns">
<aa>
</aa>

<ns:bb></ns:bb>
<ns:cc></ns:cc>

</a>

Regards

--

Abhinav
Jul 20 '05 #4


Zombie wrote:
Martin Honnen <ma*******@yahoo.de> wrote in message news:<41**********************@newsread2.arcor-online.net>...
Zombie wrote:
Can I have 2 namespaces in the same XML schema?
You need at least one schema to define elements for each namespace but
of course a schema for one namespace can import a schema for another
namespace and then reference elements from the other namespace.

Do you mean to say that 1 schema file can contain only 1 namespace?


It depends on what you mean by "contain". I clearly said that you need
one schema to define the elements for one namespace but that you need to
import the definitions of the schema for a second namespace.
Actually, 'import' is exactly what I want to avoid. That is why in the
OP, I explicitly mentioned that I want 1 schema in 1 xsd file
containing 2 namespaces.
Any way to do that?


No, if you want to validate all elements and you have elements in
differerent namespaces then you need to have one schema for every
namespace you want to define elements in.

The only thing you can do is skip validation for elements in one
namespace with
<xs:any>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #5
Abhinav <ma************@yahoo.dot.com> wrote in message news:<P3*************@news.oracle.com>...
Zombie wrote:
Martin Honnen <ma*******@yahoo.de> wrote in message news:<41**********************@newsread2.arcor-online.net>...
Zombie wrote:

Can I have 2 namespaces in the same XML schema?

You need at least one schema to define elements for each namespace but
of course a schema for one namespace can import a schema for another
namespace and then reference elements from the other namespace.

Do you mean to say that 1 schema file can contain only 1 namespace?
Actually, 'import' is exactly what I want to avoid. That is why in the
OP, I explicitly mentioned that I want 1 schema in 1 xsd file
containing 2 namespaces.
Any way to do that?


Does this help ?

(This is an example given to me by Zafar Abbas at the newsgroup
microsoft.public.xml. Google for "Schema - Definition for checking part of
schema?")

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="a">
<xs:complexType>
<xs:sequence>
<xs:group ref = "allowAny"/>
<xs:element name="aa" />
<xs:group ref = "allowAny"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:group name="allowAny">
<xs:sequence>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other" />
</xs:sequence>
</xs:group>

</xs:schema>

The following xml will be valid according to it:

<a xmlns:ns="ns">
<aa>
</aa>

<ns:bb></ns:bb>
<ns:cc></ns:cc>

</a>

Regards


Abhinav, thanks for your effort. Actually, my problem starts right
after this.
Now, I wish to come up with a second schema that will define the "bb"
and "cc" elements so that the above xml gets validated against this
new schema (bb and cc should also get validated now). As you can see,
in the xml, "bb" and "cc" are in a new namespace. So, in the new
schema too, they need to be defined in a new namespace. And that is
exactly what I am unable to do.
I hope you understand my problem.

Thanks again.
Jul 20 '05 #6

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

Similar topics

3
by: tysontate | last post by:
I've been charged with updating old schemas for various files that have never actually been validated against each other. I've got the schema itself in good form at this point - I'm positive that...
6
by: inerte | last post by:
Hello all! I need to build an XML file structure so a client can import data to one of our systems. Totally new to XML, I learned about Namespaces and DTD, and built a nice spec using them. Now...
1
by: Ryan | last post by:
I have a very complex XDR schema that uses namespaces: xmlns="urn:schemas-microsoft-com:xml-data" xmlns:b="urn:schemas-microsoft-com:BizTalkServer" xmlns:d="urn:schemas-microsoft-com:datatypes"...
3
by: John Smith | last post by:
Ok, I am not sure if it is possible. But what I'm trying to do is validate an XML file with out having to add namespace in the xml. What I mean is lets say I have 2 XSD they have different...
2
by: Edward Diener | last post by:
I could not find an example of an inline XSD schema for an XML document which has no namespaces. Could someone supply one ? When I tried validating my XML with an inline XSD schema, using...
1
by: E11 | last post by:
Hi all, I am composing a SOAP request message from a WSDL definition, and it seems that my concept of namespaces is wrong. The "types" section of the WSDL definition is as follows: ...
16
by: TT (Tom Tempelaere) | last post by:
Hi all, I created an XSD to define the structure of an XML file for my project. I made an XML file linked to the XSD using XmlSpy. The problem is that if I read the file using .NET XmlDocument...
7
by: Grant Robertson | last post by:
As I am learning about XML I seen that xmlns is used with a colon after it as if it were a namespace itself. However, I have never seen a URI given for it. Is "xmlns" a sort of predefined word in...
0
by: theonlydavewilliams | last post by:
Hi there I'm hoping there's an easy answer to a (hopefully) not too long-winded issue... I'm building a C# web client using a proxy wsdl.exe'd from a wsdl file and six schemas, each in a different...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.