Project

Profile

Help

XSD validation error messages with SaxonEE are not consistent

Added by Marjon Roodzant almost 5 years ago

Hi,

Can anyone help me to make the xsd validation error message that SAXONEE gives at least consistent? Do I need another version of saxon? Is there a possiblitity for configuration here? Is it a (known) bug?

When I perform an xsd validation on an xml that is not valid because an expected element is not provided, The error message refers to a different element element every time

[user@server saxontest]$ **java -cp saxon9ee.jar com.saxonica.Validate -xsd:opvoeren_of_opzoeken_natuurlijk_persoon_request-1.1.xsd -s:test.xml**
Validation error on line 25 column 34 of test.xml:
  FORG0001: In content of element <NatuurlijkPersoon>: The content model does not allow
  element <Q{.../1}Kanaal> to appear immediately after element <Q{.../1}RelatieId>.** It must
  be preceded by <Q{.../1}Voornamen>.**
  See http://www.w3.org/TR/xmlschema-1/#cvc-complex-type clause 2.4
Validation error on line 29 column 50 of test.xml:
  FORG0001: One validation error was reported
Validation of file test.xml completed: errors found
**[user@server saxontest]$ java -cp saxon9ee.jar com.saxonica.Validate -xsd:opvoeren_of_opzoeken_natuurlijk_persoon_request-1.1.xsd -s:test.xml**
Validation error on line 25 column 34 of test.xml:
  FORG0001: In content of element <NatuurlijkPersoon>: The content model does not allow
  element <Q{.../1}Kanaal> to appear immediately after element <Q{.../1}RelatieId>.** It must
  be preceded by <Q{.../1}Achternaam>.**
  See http://www.w3.org/TR/xmlschema-1/#cvc-complex-type clause 2.4
Validation error on line 29 column 50 of test.xml:
  FORG0001: One validation error was reported
Validation of file test.xml completed: errors found
**[user@server saxontest]$ java -cp saxon9ee.jar com.saxonica.Validate -xsd:opvoeren_of_opzoeken_natuurlijk_persoon_request-1.1.xsd -s:test.xml**
Validation error on line 25 column 34 of test.xml:
  FORG0001: In content of element <NatuurlijkPersoon>: The content model does not allow
  element <Q{.../1}Kanaal> to appear immediately after element <Q{.../1}RelatieId>.** It must
  be preceded by <Q{.../1}Roepnaam>.**
  See http://www.w3.org/TR/xmlschema-1/#cvc-complex-type clause 2.4
Validation error on line 29 column 50 of test.xml:
  FORG0001: One validation error was reported
Validation of file test.xml completed: errors found
**[user@server saxontest]$ java -cp saxon9ee.jar com.saxonica.Validate -xsd:opvoeren_of_opzoeken_natuurlijk_persoon_request-1.1.xsd -s:test.xml**
Validation error on line 25 column 34 of test.xml:
  FORG0001: In content of element <NatuurlijkPersoon>: The content model does not allow
  element <Q{.../1}Kanaal> to appear immediately after element <Q{.../1}RelatieId>. **It must
  be preceded by <Q{.../1}GeboorteDatum>.**
  See http://www.w3.org/TR/xmlschema-1/#cvc-complex-type clause 2.4
Validation error on line 29 column 50 of test.xml:
  FORG0001: One validation error was reported
Validation of file test.xml completed: errors found

The relevant xsd fragment is as follows

   <xs:complexType name="NatuurlijkPersoonType">
      <xs:sequence>
         <xs:element name="RelatieId" type="req:ANWBRelatieNummerType" minOccurs="0" maxOccurs="1"/>
         <xs:element name="Voorletters" type="req:VoorlettersType" minOccurs="0" maxOccurs="1"/>
         <xs:element name="Voornamen" type="req:NaamType" minOccurs="0" maxOccurs="1"/>
         <xs:element name="Roepnaam" type="req:NaamType" minOccurs="0" maxOccurs="1"/>
         <xs:element name="Geslacht" type="req:GeslachtCodeType" minOccurs="0" maxOccurs="1"/>
         <xs:element name="GeboorteDatum" type="xs:date" minOccurs="0" maxOccurs="1"/>
         <xs:element name="GeboortePlaats" type="req:NietLegeStringType" minOccurs="0" maxOccurs="1"/>
         <xs:element name="Titel" type="req:TitelType" minOccurs="0" maxOccurs="unbounded"/>
         <xs:element name="Achternaam" type="req:AchternaamType" minOccurs="1" maxOccurs="1"/>
         <xs:element name="Kanaal" type="req:KanaalType" minOccurs="0" maxOccurs="1"/>
      </xs:sequence>
   </xs:complexType>

The relevant xml fragment is

  <req:NatuurlijkPersoon>
       <req:RelatieId>274393144</req:RelatieId>
        <req:Kanaal>
              <req:KanaalCode>ANWB.NL</req:KanaalCode>
          </req:Kanaal>
  </req:NatuurlijkPersoon>

the saxonEE jar is

<dependency>
      <groupId>net.sf.saxon</groupId>
       <artifactId>Saxon-EE</artifactId>
       <version>9.8.0.15J</version>
</dependency>

Replies (3)

Please register to reply

RE: xsd validation errormessages with SaxonEE are not consistent - Added by Marjon Roodzant almost 5 years ago

Sorry, of course xml elements are not rendered correctly, and I cannot correct the input.

... after element <NatuurlijkPersoon>

Every example given shows one of the following

It must be preceded by &lt;Q{.../1}GeboorteDatum>.

It must be preceded by &lt;Q{.../1}Roepnaam>.

It must be preceded by &lt;Q{.../1}Achternaam>.

It must be preceded by &lt;Q{.../1}Voornamen>.

I would expect is to be

  • the same every time
  • <Q{.../1}Achternaam> by preference because that is the only required element
  • as an alternative it could list all elementnames allowed directly after <RelatieId>

RE: xsd validation errormessages with SaxonEE are not consistend - Added by Michael Kay almost 5 years ago

Thanks for reporting it, I'll look into it. The intended behaviour is that when a transition from X to Y isn't allowed, we look for all possible elements W such that X-W-Y would be allowed, and the message you are seeing should be produced only if W is a singleton set; if there are multiple possible W's, the message should say so. This clearly isn't happening.

RE: xsd validation errormessages with SaxonEE are not consistend - Added by Michael Kay almost 5 years ago

Thanks for reporting this. I have logged it as a bug here:

https://saxonica.plan.io/issues/4214

and will produce a patch (it's caused by a very simple coding error).

    (1-3/3)

    Please register to reply