complex type schema

Discussion in 'XML' started by motorpage@gmail.com, Oct 22, 2007.

  1. Guest

    Hi,

    I am a newbie to schema definitions so forgive me if this is a simple
    question.

    I am trying to create a schema for a complex type that allows
    instances of either of the two forms:

    <test1 state=true>
    <name>test1/>
    <type>typeA/>
    </test1>

    <test2 state=false>
    <name>test2/>
    <type>type@/>
    </test2>

    Here the 'type' element is a string without the '@' character if
    'state' is true and a string with the '@' character when state is
    false.
    , Oct 22, 2007
    #1
    1. Advertising

  2. wrote:
    > I am trying to create a schema for a complex type that allows
    > instances of either of the two forms:
    >
    > <test1 state=true>
    > <name>test1/>
    > <type>typeA/>
    > </test1>
    >
    > <test2 state=false>
    > <name>test2/>
    > <type>type@/>
    > </test2>


    XML Schemas don't allow you to select between two different types of
    content based on the value of a variable -- *EXCEPT* by making the two
    types of content subtypes of a single type, and then using the xsi:type
    attribute to switch between them. If you are willing to replace your
    "state" with that directive, you can make this work. Otherwise, do this
    cross-dependency check in your application code, or investigate whether
    your environment supports any of the other schema languages.

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
    Joseph Kesselman, Oct 22, 2007
    #2
    1. Advertising

  3. Guest

    I'm just starting to get my head around XML Schemas. I found XML
    Studio really good for learning the basics, and its free

    http://www.liquid-technologies.com/Product_XmlStudio.aspx

    Regards Jason

    On 22 Oct, 19:40, wrote:
    > Hi,
    >
    > I am a newbie to schema definitions so forgive me if this is a simple
    > question.
    >
    > I am trying to create a schema for a complex type that allows
    > instances of either of the two forms:
    >
    > <test1 state=true>
    > <name>test1/>
    > <type>typeA/>
    > </test1>
    >
    > <test2 state=false>
    > <name>test2/>
    > <type>type@/>
    > </test2>
    >
    > Here the 'type' element is a string without the '@' character if
    > 'state' is true and a string with the '@' character when state is
    > false.
    , Oct 23, 2007
    #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. Markus
    Replies:
    1
    Views:
    1,497
    Markus
    Nov 23, 2005
  2. Rich Weed
    Replies:
    0
    Views:
    1,619
    Rich Weed
    Jul 16, 2003
  3. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,173
    Stanimir Stamenkov
    Apr 25, 2005
  4. Stanimir Stamenkov
    Replies:
    2
    Views:
    734
    Stanimir Stamenkov
    Oct 25, 2005
  5. Robert Mark Bram
    Replies:
    0
    Views:
    673
    Robert Mark Bram
    Feb 4, 2007
Loading...

Share This Page