XML conforming to multiple Schemas simultaneously

A

Alex Rootham

Hi,

I'm quite new to schema design, and was wondering if someone might
point out what I'm doing wrong when designing my Schema's

I have a need to do the following:

Schema1.xsd -- defines generic types/elements
Schema2.xsd -- defines specific types/elements
file1.xml -- an example xml that needs to conform to both schemas.



So, for example, Schema1.xsd defines a complex-type "subsystem".
Shema2.xsd also defines complex-type "subsystem", and in fact,
Schema2's subsystem is a specialization of Schema1's subsystem.

Thus, I want file1.xml to conform to Schema2's subsystem -- however, I
need auto-generated code from Schema1.xsd to properly parse file1.xml
-- file1.xml needs to conform to both Schema1.xsd and Schema2.xsd.

Example:

Schema1.xsd --
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:complexType name="subsystemType" mixed="true">
... generic...
</xs:complexType>
</xs:schema>

Schema2.xsd --
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:complexType name="subsystemType" mixed="true">
... specific example of generic from Schema1.xsd ...
</xs:complexType>
</xs:schema>


file1.xml --
<subsystem type="subsystemType">specific example</subsystem>



My question is -- how should I elate Schema1.xsd, Schema2.xsd and
file1.xml? Since Schema2.xsd is a specialization of Schema1.xsd, my
gut reaction was to derive the underlying types -- however, I cannot
do this in the case of having multiple specializations of subsystems.



Thanks for any help!
Alex
 
R

Richard Tobin

Alex Rootham said:
Schema1.xsd -- defines generic types/elements
Schema2.xsd -- defines specific types/elements
file1.xml -- an example xml that needs to conform to both schemas.

This sounds like a natural case for xs:redefine, which allows you
to include Schema1.xsd in Schema2.xsd and define a more specific
subsystemType derived from the generic one.

But I don't understand your last sentence:
I cannot
do this in the case of having multiple specializations of subsystems.

Do you mean that in one file you have multiple instances of the same
element with types that are different specializations of
subsystemType? If so, you could define several types derived from
subsystemType and use local element declarations to select the
appropriate one.

-- Richard
 
R

Richard Tobin

If so, you could define several types derived from subsystemType and
use local element declarations to select the appropriate one.

I'm not sure how to do this, because it is not valid to have a schema
whereby you have two "subsystem" tags which are of different type.[/QUOTE]

It is if they are *local* element declarations. That is, if you
declare them inside the content model for the containing elements.
Obviously this will only work if the two cases are distinguished
by which element they appear inside.

-- Richard
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top