How to specify at least one in the xsd sequence:

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 at least one element from YY or ZZ to be present, both of them may be absent in the above.

+3
source share
1 answer

I believe this is what you are 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>
+2
source

Source: https://habr.com/ru/post/1759048/


All Articles