Simple question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Volker Zink

    Simple question

    I am writing my first schema and have 3 complex types which represent
    "top level objects":

    <complex type name="A1">
    ....
    </complex type>

    <complex type name="A2">
    ....
    </complex type>

    <complex type name="A3">
    ....
    </complex type>


    In the XML-Document i want that there may be any number of
    corresponding elements in any order. I.e.

    <A1></A1>
    <A2></A2>
    <A1></A1>
    <A3></A3>
    <A1></A1>
    <A2></A2>

    How do i model that in the schema?

    I can't use the union, because these are complex types, and all is not
    possible too because the number is unbounded. Is there a simple
    solution to this simple problem?

    Thanks

    Volker
  • Peter Gerstbach

    #2
    Re: Simple question

    Volker Zink wrote:[color=blue]
    > In the XML-Document i want that there may be any number of
    > corresponding elements in any order. I.e.
    >
    > <A1></A1>
    > <A2></A2>
    > <A1></A1>
    > <A3></A3>
    > <A1></A1>
    > <A2></A2>
    >
    > How do i model that in the schema?[/color]

    Declare an unbounded choice element in your schema, e.g.:

    <xs:element name="root">
    <xs:complexTy pe name="rootType" >
    <xs:choice maxOccurs="unbo unded">
    <xs:element name="A1"/>
    <xs:element name="A2"/>
    <xs:element name="A3"/>
    </xs:choice>
    </xs:complexType>
    </xs:element>

    Try it out! I hope this is what you where looking for.

    Peter

    Comment

    Working...