How to define elements in xsd as mandatory/optional and any order



I am unable to define the elements with "<xsd:all>" for below requirement,


I am getting error that "maxOccurs" should be 0 or 1 under schema "all".


Below is my requirement, could anyone please help me as soon as possible.



  1. elements (A & B) can come in any order in xml (so i am using xsd:all, but gettting error), i don't want to go with sequence.

  2. element A is mandatory, it should appear in xml always, however element B is optional.

  3. element A & B can appear any number of times for example i can have element A as 10 times and element B as 20 times.


<?xml version="1.0" encoding="utf-8"?>

<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xsd="http://ift.tt/tphNwY">

<xsd:element name="InvoiceData" >

<xsd:complexType>

<xsd:all>

<xsd:element name="A" minOccurs="1" maxOccurs="unbounded" >

<xsd:element name="B" minOccurs="0" maxOccurs="unbounded" >

</xsd:all>

</xsd:complexType>

</xsd:element>

</xsd:schema>


No comments:

Post a Comment