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

namespace of type reference

Dear all,

I have the following problem
In a schema I refer to a type in a different schema like this:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified"
targetNamespace="http://www.example.com" xmlns:test="test">

<xs:import namespace="test" schemaLocation="test.xsd"/>
<xs:element name="test">
<xs:complexType>
<xs:sequence>
<xs:element name="IncludedElement" type="test:TestType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

What I want to achieve is the following:

<?xml version="1.0" encoding="UTF-8"?>
<test xmlns="http://www.example.com" xmlns:test="test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="test test.xsd">
<test:IncludedElement>
<test:SomeElements/>
<test:IncludedElement/>
</test:IncludedElement>
</test>

But this is what I get

<?xml version="1.0" encoding="UTF-8"?>
<test xmlns="http://www.example.com" xmlns:test="test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="test test.xsd">
<IncludedElement>
<test:SomeElements/>
<test:IncludedElement/>
</IncludedElement>
</test>

Using the schema above, the SomeElements and the nested IncludeElement are
of the correct namespace (test), But the "containing" IncludeElement is not
:(

I know a reference to that element instead of to that type will do the
trick, but the schema I am refering to only has only 1 global element, an I
am not able to change that schema.
Can someone help me out?

Many thanks,

Koen

Jul 20 '05 #1
3 1443


Koen De Wolf wrote:

I have the following problem
In a schema I refer to a type in a different schema like this:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified"
targetNamespace="http://www.example.com" xmlns:test="test">

<xs:import namespace="test" schemaLocation="test.xsd"/>
<xs:element name="test">
<xs:complexType>
<xs:sequence>
<xs:element name="IncludedElement" type="test:TestType"/>
If IncludedElement is supposed to be in the namespace test then you need
to define it in test.xsd and use
<xs:element ref="test:IncludedElement" />
here. Your main schema can only define elements in its targetNamespace.
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

What I want to achieve is the following:

<?xml version="1.0" encoding="UTF-8"?>
<test xmlns="http://www.example.com" xmlns:test="test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="test test.xsd">
<test:IncludedElement>
<test:SomeElements/>
<test:IncludedElement/>
</test:IncludedElement>
</test>

But this is what I get

<?xml version="1.0" encoding="UTF-8"?>
<test xmlns="http://www.example.com" xmlns:test="test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="test test.xsd">
<IncludedElement>
<test:SomeElements/>
<test:IncludedElement/>
</IncludedElement>
</test>

Using the schema above, the SomeElements and the nested IncludeElement are
of the correct namespace (test), But the "containing" IncludeElement is not
:(

I know a reference to that element instead of to that type will do the
trick, but the schema I am refering to only has only 1 global element, an I
am not able to change that schema.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
That was what I was afraid of. So it is not possible to have somehow 2
target namespaces.

Tx,

Koen

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:40********@olaf.komtel.net...


Koen De Wolf wrote:

I have the following problem
In a schema I refer to a type in a different schema like this:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified"
targetNamespace="http://www.example.com" xmlns:test="test">

<xs:import namespace="test" schemaLocation="test.xsd"/>
<xs:element name="test">
<xs:complexType>
<xs:sequence>
<xs:element name="IncludedElement" type="test:TestType"/>


If IncludedElement is supposed to be in the namespace test then you need
to define it in test.xsd and use
<xs:element ref="test:IncludedElement" />
here. Your main schema can only define elements in its targetNamespace.
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

What I want to achieve is the following:

<?xml version="1.0" encoding="UTF-8"?>
<test xmlns="http://www.example.com" xmlns:test="test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="test test.xsd">
<test:IncludedElement>
<test:SomeElements/>
<test:IncludedElement/>
</test:IncludedElement>
</test>

But this is what I get

<?xml version="1.0" encoding="UTF-8"?>
<test xmlns="http://www.example.com" xmlns:test="test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="test test.xsd">
<IncludedElement>
<test:SomeElements/>
<test:IncludedElement/>
</IncludedElement>
</test>

Using the schema above, the SomeElements and the nested IncludeElement are of the correct namespace (test), But the "containing" IncludeElement is not :(

I know a reference to that element instead of to that type will do the
trick, but the schema I am refering to only has only 1 global element, an I am not able to change that schema.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3


Koen De Wolf wrote:
That was what I was afraid of. So it is not possible to have somehow 2
target namespaces.


One schema has one target namespace and can only define elements in that
target namespace, any element in another namespace needs to be defined
in a separate schema that is then imported and the element is referenced.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #4

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

Similar topics

1
by: John L. Clark | last post by:
I am curious as to the rationale, and effect, of having default namespaces not applying (directly) to attributes (see http://www.w3.org/TR/REC-xml-names/#defaulting). Given an attribute without a...
2
by: dimension | last post by:
Hi, in visual studio 2005 beta, when i type "using System.Web." no code complete helper pops up. Similarly, when typing "using System.Net." i do not see an HttpWebRequest in the list that pops...
6
by: clinton__bill | last post by:
Hi, I usually use "using namespace <namespace_name>" to reference a namespace. Today I run across a code, in its header file it has this, namespace SP1{ class C1; } While SP1::C1 is a...
29
by: Tiraman | last post by:
Hi, I Build my own dll with my own namespace name and i would like to put it in one place but for the project bin folder so all of the projects will be able to use it . i tried to put the dll...
0
by: Steven Bolard | last post by:
Hello, I am trying to port my .net 1.1 application to 2.0. I am using vs2005. I am trying to get my webservices to run and although i can compile them and and get wsdl and service descriptions...
1
by: SMart | last post by:
I am having a problem with a C# dll in my Visual Studio 2005 ASP.NET web site project: when I add a reference to a certain the dll, it tells me that the type or namespace “Log” does not exist in the...
0
by: SMart | last post by:
I am having a problem with a C# dll in my Visual Studio 2005 ASP.NET web site project: when I add a reference to a certain the dll, it tells me that the type or namespace “Log” does not exist in the...
3
by: sjt003 | last post by:
I have been developing web apps in Visual Studio 2003, but since the other developers in my office don't use Visual Studio, I may have to stop too unless there is an efficient way for them to...
4
by: vncntj | last post by:
I've tested this project locally, by running it http://localhost:1436/Data/gift.aspx and everything is perfect. But if it onto the remote server I get "The type or namespace name could not be...
4
by: Jon | last post by:
I have an example C# programme which shows me how to communicate with a scientist instrument. It includes the namespace statement "using Ivi.Visa.Interop" If I copy this into a blank winform...
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
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
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,...

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.