views:

29

answers:

1

I have an XSD - it is designed to allow clients to my webservice to send XML data in a structured and robust way (that's the whole point of XSDs right?).

However I am designing some other part of the system and was going to use this XSD because it does 99.999999% of what I need it to do - it has all the data I could ever want - except it is missing an element that I need it to hold - a database primary key value.

So you may be thinking - whats your problem, just add the element to the XSD and get on with it! Well yes I could, but the problem is - the client side of the system would not know what to do with this element (leave it blank??), - they don't have to put in a primary key value in, actually impossible for them to do so! - makes sense really, if you are sending data to the database, its the database that makes the primary key value, not the person sending it.

So what do I do? Do I make 2 almost identical XSDs (one with a primary key value element, and one without) or just try and 'shoehorn' everything into one XSD, but as a side effect cause possible confusion?

+2  A: 

Can't you use inheritance, see this article. Then you can create a second xsd that references the first and adds the field you need.

Mark Dickinson
hmmm seems like a bit of a fudge this one - and not sure if it will work with JAXB or XML Schema Definition Tool from Microsoft. But thanks.
Vidar
I would go with Mark's answer. JAXB will support this, and the XSD tools from microsoft will, too.You may want to put your extended schema in a separate namespace, then import the original schema.
xcut