I have an XSD and incorrect XML.
The XSD has a complex type with a sequence of elements. All those elements are mandatory. (The XSD is maintained by a 3rd party and can't be changed)
The incorrect XML is missing one element.
When I validate the XML against the XSD using C#, the expected error is "the 'XXX' element is expected". But actually, it also tells me "the element has invalid child element". I'm not sure what should I do.
To help you understand my question, I'll show you an example:
<!-- Incorrect XML -->
<class>
<el1>222</el1>
<el3>222</el3>
</class>
<!-- XSD -->
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="class">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:short" name="el1" />
<xs:element type="xs:short" name="el2" />
<xs:element type="xs:short" name="el3"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The real but unexpected validation errors are something like below:
The element 'class' has invalid child element 'el3'. List of possible elements expected: 'el2'.
The expected errors are:
List of possible elements expected: 'el2'.