tags:

views:

10

answers:

1

I have a sequence

<xs:element name="XXXX">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref="YY" minOccurs="0" maxOccurs="unbounded"/>
      <xs:element ref="ZZ" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

but I would like that at least one element of YY or ZZ to be present, in the above both are allowed to be missing.

+1  A: 

I belive this is what you're looking for:

<xs:element name="XXXX">
  <xs:complexType>
    <xs:sequence>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="YY" />
        <xs:element ref="ZZ" />
      </xs:choice>
    </xs:sequence>
  </xs:complexType>
</xs:element>
Cirdec
Excellent, thanks a lot
BuggerMe
If you want at least one you need to change minOccurs to 1
Cirdec
gotcha, thanks!
BuggerMe