Attribute 'maxOccurs' cannot appear in element 'element' ..!!!! :(
843834Jun 19 2007 — edited Jun 19 2007Hi I am trying to validate an xml against the schema..and i get the following error :
Attribute 'maxOccurs' cannot appear in element 'element'
where my xsd is :
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="_Record_" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="ParCo" type="xs:string"/>
<xs:element name="PrdId" type="xs:integer"/> <xs:element name="EventID" type="xs:integer"/>
<xs:element name="ProdCaID" type="xs:string"/>
<xs:element name="EvStDa" type="xs:long"/>
<xs:element name="Volume" type="xs:integer"/>
<xs:element name="UOM1" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
and the given xml is :
<_Record_>
<EventID>1</EventID>
<EvStDa>20050101010101</EvStDa>
<ParCo>DUMMYPRT</ParCo>
<UOM1>KB</UOM1>
<Volume>10</Volume>
<PrdId>1</PrdId>
<ProdCaID>PC</ProdCaID>
</_Record_>
even if i remove the maxoccurs thing i still en error like :
Invalid content starting with element 'EventID'. One of '{"":ParCo}' is expected.
the only workaround i find is removing maxoccurs and sorting the elements in the sequence given in XSD. i.e somewhat like this :
<_Record_>
<ParCo>DUMMYPRT</ParCo>
<PrdId>1</PrdId>
<EventID>1</EventID>
<ProdCaID>PC</ProdCaID>
<EvStDa>20050101010101</EvStDa>
<Volume>10</Volume>
<UOM1>KB</UOM1>
</_Record_>