views:

190

answers:

1

Hello,

I'm trying to create an element in a schema where its sub-types can appear in any order and as many times as necessary:

    <xs:element name="workflowNodes">
 <xs:complexType>
  <xs:sequence minOccurs="0" maxPO>
   <xs:element ref="nodeType1" />
   <xs:element ref="nodeType2" />
   <xs:element ref="nodeType3" />
   <xs:element ref="nodeType4" />
  </xs:sequence>
 </xs:complexType>
</xs:element>

where the nodes nodeType(n) can be in any order and be repetitive as necessary.

Also, I tried :

But the compiler is not working complaining the nodeType2 is not valid when there is not nodeType1.

What am I missing here?

Thanks in advance.

+2  A: 

You should be able to get your results by doing this:

<xs:element name="workflowNodes">
        <xs:complexType>
                <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:element ref="nodeType1" />
                        <xs:element ref="nodeType2" />
                        <xs:element ref="nodeType3" />
                        <xs:element ref="nodeType4" />
                </xs:choice>
        </xs:complexType>
</xs:element>

<xs:choice> gives you the option to pick one of the elements, and making the xs:choice appear many times allows you to pick each element as many times as you like.

Marc

marc_s