Combining Multiple XSD Files into One Schema

Posted on 2011-10-31
Medium Priority
Last Modified: 2012-08-14

We have a server application that can return one of 5different XML responses to a caller. These responses are described by separate XSD files. Let's call them A.xsd, B.xsd, C.xsd, D.xsd and E.xsd. We have control of the namespace, etc., so that does not represent an issue.

Now, I want to take the 5 different XSD files and create a single XSD that can be used to validate any of the messages (A, B, C, D or E).

How would I go about building a single XSD that accomplishes this?

I have looked at using complexType, choice, etc., but the options are confusing.

I have attached 2 of the XSD files that I'd like to combine into one...


Question by:rapidbuyr
1 Comment
LVL 60

Accepted Solution

Geert Bormans earned 2000 total points
ID: 37061625
Well, this is a bit a tricky task.
In fact you more or less need to do the modelling all over

In a first view you can throw all stuff together
The structure is almost the same and the main difference is that a "Response" has a "recordset" with a number of "tns:Result" as child for criminal.xsd and a number of "record" in evictions.xsd

You could add a choice

<xs:element name="Response">
                        <xs:element ref="tns:stats"/>
                              <xs:element ref="tns:recordset"/>
                              <xs:element maxOccurs="unbounded" ref="tns:record"/>

so this now covers both xsd.

But, the model for tns:stats/tns:searchInput is different. Also there you could make a choice between the complex type of the simple string type one way or another.
So you can make a combined model, BUT
... something you can't model is that tns:stats/tns:searchInput should be a simple string when there is a recordset, and have a somewhat more complex model when there are multiple records
That is a co-occurence constraint, and that can't be modelled in a xsd, without help from schematron

So bringing to schemata together already gives a less strict schema over having two different schemata,
I am not sure how acceptable that is

I hope you understand this would even get worse with 5 schemata

Please consider carefully why you want to do this.
I have a feeling that it would be more powerfull to guess teh schema from the result that comes in
and dynamically attach the correct schema to your XML.
It is going to be a lot more robust
In order to get it right, you are in for a complex redesign (if at all feasible, I have only seen two of the 5 schemata)

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These instructions are based on installing Owncloud on your new raspberry pi connected with a usb HDD. What do you need Part A? A Raspberry Pi, model B. A boot SD card for the Raspberry Pi. A usb HDD An Ethernet cable to connect to the lo…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question