Help interpreting validation errors

This should cover W3C XML Schema, Relax NG and DTD related problems.
thevenkster
Posts: 2
Joined: Tue Mar 26, 2019 1:50 pm

Help interpreting validation errors

Post by thevenkster » Tue Mar 26, 2019 2:06 pm

Hi:

I am validating an XML document against an XSD. A snippet of the offending XSD is below:
<xs:element name="record">
<xs:complexType>
<xs:sequence>
<xs:element name="recordID" type="string100"/>
<xs:element name="recordUserId" type="string30" minOccurs="0" maxOccurs="1"/>
<xs:element name="recordDeletedDate" type="xs:dateTime" minOccurs="0" maxOccurs="1"/>
<xs:element name="termType" type="string100"/>
<xs:element name="repTerm" type="string4000"/>
<xs:element name="altTerm" type="string4000" minOccurs="0" maxOccurs="1"/>
<xs:element name="repAltApproved" type="string1" minOccurs="0" maxOccurs="1"/>
<xs:element name="intCode" type="string50" minOccurs="0" maxOccurs="1"/>
<xs:element name="intTerm" type="string4000" minOccurs="0" maxOccurs="1"/>
<xs:element name="intPrefCode" type="string50" minOccurs="0" maxOccurs="1"/>
<xs:element name="intPrefTerm" type="string4000" minOccurs="0" maxOccurs="1"/>
<xs:element name="intCodeDate" type="xs:dateTime" minOccurs="0" maxOccurs="1"/>
<xs:element ref="recordInfo" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>

and I get the following errors:

Element <termType> is not allowed at this location under element <record>.
Reason: The following elements are expected at this location (see below)
'recordID'
Error location: MPWS / body / records / record / termType
Details
cvc-complex-type.1.4: Element <termType> unexpected at this location by type '{anonymous}' of element <record>.
cvc-type.3.2: Element <record> is not valid with respect to type definition '{anonymous}'.
cvc-elt.5.2.1: The element <record> is not valid with respect to the actual type definition '{anonymous}'.
Element <termType> is not allowed at this location under element <record>.
Reason: The following elements are expected at this location (see below)
'recordID'
Error location: MPWS / body / records / record / termType
Details
cvc-complex-type.1.4: Element <termType> unexpected at this location by type '{anonymous}' of element <record>.
cvc-type.3.2: Element <record> is not valid with respect to type definition '{anonymous}'.
cvc-elt.5.2.1: The element <record> is not valid with respect to the actual type definition '{anonymous}'.

I am no able to interpret the error. Can someone advise me?

Venki

thevenkster
Posts: 2
Joined: Tue Mar 26, 2019 1:50 pm

Re: Help interpreting validation errors

Post by thevenkster » Tue Mar 26, 2019 4:18 pm

Well, a little research taught me something new!

The key is xs:sequence. If this is used, the elements in the XML have to be in the same order as specified in the XSD.

As opposed to xs:all in which case the order can be different.

Venki

Post Reply