namespace of type reference

Koen De Wolf

Usenet Archive
Joined
Dec 1, 2003
Messages
5
Reaction score
0
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
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
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
 

Koen De Wolf

Usenet Archive
Joined
Dec 1, 2003
Messages
5
Reaction score
0
That was what I was afraid of. So it is not possible to have somehow 2 target namespaces.

Tx,

Koen
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
Koen said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top