I have been wondering about a simple but very important question.
I have a parent element that is optional because of minOccurs="0" but its child elements do not have any minOccurs or maxOccures attributes defined.
Am I right that in case the parent element occurs, all its child elements are mandatory?
My example code looks like this:
name="FiscalRepresentativeInfo" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="FiscalRepresentativeTaxRegistrations" type="MandatoryTaxNumbersType"></xs:element>
<xs:element name="FiscalRepresentativeName" type="LongStringType"></xs:element>
<xs:element name="FiscalRepresentativeAddress" type="AddressType"></xs:element>
<xs:element name="FiscalRepresentativeBankAccountNumber" type="BankAccountNumberType"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Now, my question in practical terms is this:
- The fiscal representative info is optional, the XML instance may or may not contain it.
- Here comes the point: in case there is a fiscal representative info in the XML, it MUST have all 4 elements. For example, it is not possible to miss the bank account number.
Please let me know whether my understanding above is correct.