tags:

views:

726

answers:

1

I need to create an XML schema that looks something like this:

<xs:element name="wrapperElement">
<xs:complexType>
    <xs:sequence>
        <xs:element type="el1">
        <xs:element type="el2">
    </xs:sequence>

    <xs:WhatGoesHere?>
        <xs:element type="el3"> 
        <xs:element type="el4">
        <xs:element type="el5">
    </xs:WhatGoesHere?>

    <xs:sequence>
        <xs:element type="el6">
        <xs:element type="el7">
    </xs:sequence>
</xs:complexType>
</xs:element>

What I need is a replacement for "WhatGoesHere" such that any number of el3, el4 and el5 can appear in any order. For instance it could contain {el3, el3, el5, el3}

Any idea on how to solve this?

+8  A: 

You want xs:group with occurrence constraints:

<xs:element name="wrapperElement">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="e11"/>
      <xs:element name="el2"/>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="el3"/>
        <xs:element name="el4"/>
        <xs:element name="el5"/>
      </xs:choice>
      <xs:element name="el6"/>
      <xs:element name="el7"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>
jelovirt