I’ve set the element "FURNITURE" to minOccurs="0" but it still comes back
Element ‘FURNITURE’ cannot be empty according to the DTD/Schema.
when I try to validate it
<xsd:element name="FURNITURE" minOccurs="0" maxOccurs="6">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ID" type="xsd:integer" />
<xsd:element name="rNumber" type="xsd:string" />
<xsd:element name="type" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
and
<FURNITURE />
>Solution :
By placing minOccurs="0" on FURNITURE, you’re specifying that FURNITURE need not be present, but that says nothing about the content model of FURNITURE. In fact, FURNITURE must consist of a sequence of ID, rNumber, and type elements which must all be present exactly once.
If you want FURNITURE to possibly be empty when present, then make each of those child elements optional individually by adding minOccurs="0" to each xsd:element or collectively by adding minOccurs="0" to the wrapping xsd:sequence.
See also
- XML Schema minOccurs / maxOccurs default values
- XML Schema: usage of minOccurs and maxOccurs within xs:sequence