XML conforming to multiple Schemas simultaneously

Discussion in 'XML' started by Alex Rootham, Aug 26, 2003.

  1. Alex Rootham

    Alex Rootham Guest

    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
    Alex Rootham, Aug 26, 2003
    #1
    1. Advertising

  2. In article <>,
    Alex Rootham <> wrote:

    >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
    --
    Spam filter: to mail me from a .com/.net site, put my surname in the headers.

    FreeBSD rules!
    Richard Tobin, Aug 26, 2003
    #2
    1. Advertising

  3. In article <3f4cbeb0$0$62082$>,
    Alex Rootham <> wrote:

    >> 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.


    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
    --
    Spam filter: to mail me from a .com/.net site, put my surname in the headers.

    FreeBSD rules!
    Richard Tobin, Aug 28, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jimmy
    Replies:
    1
    Views:
    458
    bruce barker
    Jul 8, 2003
  2. Sebastian Millies
    Replies:
    0
    Views:
    367
    Sebastian Millies
    Mar 9, 2005
  3. Tony Prichard
    Replies:
    0
    Views:
    715
    Tony Prichard
    Dec 12, 2003
  4. Peter Rooney

    tool to fix non-conforming xml?

    Peter Rooney, Feb 5, 2006, in forum: XML
    Replies:
    2
    Views:
    551
    Henry S. Thompson
    Feb 6, 2006
  5. Andy B
    Replies:
    0
    Views:
    368
    Andy B
    Aug 7, 2008
Loading...

Share This Page