Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 08:09 AM
Koen De Wolf
Guest
 
Posts: n/a
Default 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





  #2  
Old July 20th, 2005, 08:09 AM
Martin Honnen
Guest
 
Posts: n/a
Default Re: namespace of type reference



Koen De Wolf wrote:

[color=blue]
> 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"/>[/color]

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.
[color=blue]
> </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.[/color]


--

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

  #3  
Old July 20th, 2005, 08:09 AM
Koen De Wolf
Guest
 
Posts: n/a
Default Re: namespace of type reference

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

Tx,

Koen

"Martin Honnen" <mahotrash@yahoo.de> wrote in message
news:4073dab8$1@olaf.komtel.net...[color=blue]
>
>
> Koen De Wolf wrote:
>
>[color=green]
> > 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"/>[/color]
>
> 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.
>[color=green]
> > </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[/color][/color]
are[color=blue][color=green]
> > of the correct namespace (test), But the "containing" IncludeElement is[/color][/color]
not[color=blue][color=green]
> > :(
> >
> > 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,[/color][/color]
an I[color=blue][color=green]
> > am not able to change that schema.[/color]
>
>
> --
>
> Martin Honnen
> http://JavaScript.FAQTs.com/
>[/color]


  #4  
Old July 20th, 2005, 08:09 AM
Martin Honnen
Guest
 
Posts: n/a
Default Re: namespace of type reference



Koen De Wolf wrote:
[color=blue]
> That was what I was afraid of. So it is not possible to have somehow 2
> target namespaces.[/color]

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/

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles