0

I have a set of XSD files each having the following structure:

message_i.xsd

<xs:complexType name="message_i">
    <!-- definition of message -->
</xs:complexType>

<xs:element name="document" type="message_i"></xs:element>

So each of the xsd-files contains an element called "document" of type that file defines. The xsd-files are being used by a webservice that receives messages of specific "document" types.

The man thing is that I need to have a bunch of elements "document" but of different types.

Now I want to combine several messages into one. I created the following code:

<!-- some data -->
<xs:element name="document1" type="message1">
<xs:element name="document4" type="message4">    
<xs:element name="document5" type="message5">

But I get the error stating that this document contains element that already exists in the target namespace. And that name is "document".

How can I create an element that contains different messages?

1 Answer 1

1

Can't see that without without defining each complex type in each xsd, but

Add a namespace to each xsd

e.g.

<xs:schema xmlns:DOC1="http://www.mySite.Com/DOC1" />

Then your complex type would be DOC1:message_i

so you could have,

<xs:element name="document1" type="DOC1:message_i">
<xs:element name="document4" type="DOC2:message_i">
<xs:element name="document5" type="DOC3:message_i"> 
1
  • Do i have to add targetNamespace to each XSD? After doing like you said i get an error stating that link to DOC1:message_1 is prohibited
    – kbeat
    Oct 23, 2012 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.