xsd two alternative optional tag



I am trying to validate some xml like this:



<Rpms>
<Rpm>path/file.rpm</Rpm>
<SlImport>path/file.xml</SlImport>
<Rpms>


The tags Rpm and SlImport follow these rule:



  1. are both optional

  2. may appear more than once

  3. may appear in any order, whether or not mixed

  4. at least one (Rpm or SlImport) tag must be present


I wrote this xsd:



<xs:element name="Rpms">
<xs:complexType>
<xs:sequence>
<xs:choice maxOccurs="unbounded">
<xs:element name="SlImport" type="SlElement" minOccurs="0" />
<xs:element name="Rpm" type="rpmElement" maxOccurs="unbounded">
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>


It works fine, except in this case: it doesn't throw error if Rpms tag is empty.


No comments:

Post a Comment