I am using the following schema to check the following XML file. And I find when there is more than one Information elements inside People elements, the schema check will fail. Why and how to fix it (I want to allow People element to be able to nest more than one Information items)?
XML Schema file:
<xs:element name="People">
<xs:complexType>
<xs:sequence>
<xs:element name="Information">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
</xs:sequence>
<xs:attribute name="Id" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
XML file (schema check will fail):
<People>
<Information Id="1">
<Name>John</Name>
</Information>
<Information Id="2">
<Name>Mike</Name>
</Information>
</People>
XML file (schema check will success):
<People>
<Information Id="1">
<Name>John</Name>
</Information>
</People>
thanks in advance, George
If you dont specify minOccurs and maxOccurs with the sequence, the default value is 1.
<xs:element name="Information" minOccurs = "1" maxOccurs = "unbounded">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With