namespace of type reference

K

Koen De Wolf

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
 
M

Martin Honnen

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
 
K

Koen De Wolf

That was what I was afraid of. So it is not possible to have somehow 2
target namespaces.

Tx,

Koen
 
M

Martin Honnen

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

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top