Bug #5208
closedInvalid values for a field with a uniqueness constraint cause validator to crash after reporting the first error.
100%
Description
When validating an XML file containing a non-integer string "1A" in an integer field, we discovered Saxon validation to exit abnormally with a SAXException. It seems that the field itself is validated successfully and an error is normally reported to the ErrorHandler, but a later endElement() processing fails and returns a ValidationException.
This is somehow related to the schema we are validating against: I can reproduce the problem by using the full schema, but when I tried to create a minimal schema with the same elements and restrictions, the validation completed normally.
The exception occurs when validating the "sequence" field, defined as follows:
<xs:element name="sequence" minOccurs="0">
<xs:simpleType>
<xs:restriction base="cus:numeric">
<xs:minInclusive value="1"/>
<xs:pattern value="[1-9][0-9]*"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
And the "cus:numeric" the restriction it is based on is:
<xs:simpleType name="numeric">
<xs:restriction base="xs:integer"/>
</xs:simpleType>
We do not own the schema ourselves, so we cannot try to circumvent the problem by changing the schema.
I've attached a simple test program for reproducing the error. The package contains the full schema and a failing xml file. Consult the README file for compile & execute instructions.
Just in case it helps, here are the relevant parts from the stacktrace we get in production:
Caused by: org.xml.sax.SAXException: Cannot convert string "1A" to an integer
at com.saxonica.ee.jaxp.ValidatorImpl.validate(ValidatorImpl.java:81) ~[Saxon-EE-10.6.jar:?]
at javax.xml.validation.Validator.validate(Validator.java:124) ~[?:1.8.0_301]
[...]
Caused by: net.sf.saxon.type.ValidationException: Cannot convert string "1A" to an integer
at net.sf.saxon.type.ValidationFailure.makeException(ValidationFailure.java:406) ~[Saxon-EE-10.6.jar:?]
at net.sf.saxon.type.ValidationFailure.asAtomic(ValidationFailure.java:432) ~[Saxon-EE-10.6.jar:?]
at com.saxonica.ee.validate.FieldChecker.endElement(FieldChecker.java:209) ~[Saxon-EE-10.6.jar:?]
at com.saxonica.ee.stream.watch.WatchManager.endElement(WatchManager.java:484) ~[Saxon-EE-10.6.jar:?]
at net.sf.saxon.event.TeeOutputter.endElement(TeeOutputter.java:144) ~[Saxon-EE-10.6.jar:?]
at net.sf.saxon.event.TeeOutputter.endElement(TeeOutputter.java:143) ~[Saxon-EE-10.6.jar:?]
at net.sf.saxon.event.ProxyReceiver.endElement(ProxyReceiver.java:148) ~[Saxon-EE-10.6.jar:?]
at com.saxonica.ee.validate.SimpleContentValidator.endElement(SimpleContentValidator.java:251) ~[Saxon-EE-10.6.jar:?]
at com.saxonica.ee.validate.ValidationStack.endElement(ValidationStack.java:494) ~[Saxon-EE-10.6.jar:?]
at net.sf.saxon.event.ProxyReceiver.endElement(ProxyReceiver.java:148) ~[Saxon-EE-10.6.jar:?]
at net.sf.saxon.event.ProxyReceiver.endElement(ProxyReceiver.java:148) ~[Saxon-EE-10.6.jar:?]
at com.saxonica.ee.validate.AttributeInheritor.endElement(AttributeInheritor.java:62) ~[Saxon-EE-10.6.jar:?]
at net.sf.saxon.event.PathMaintainer.endElement(PathMaintainer.java:62) ~[Saxon-EE-10.6.jar:?]
at net.sf.saxon.event.DocumentValidator.endElement(DocumentValidator.java:78) ~[Saxon-EE-10.6.jar:?]
at net.sf.saxon.event.ReceivingContentHandler.endElement(ReceivingContentHandler.java:570) ~[Saxon-EE-10.6.jar:?]
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) ~[xercesImpl-2.12.1.jar:?]
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) ~[xercesImpl-2.12.1.jar:2.12.1]
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) ~[xercesImpl-2.12.1.jar:2.12.1]
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) ~[xercesImpl-2.12.1.jar:2.12.1]
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) ~[xercesImpl-2.12.1.jar:?]
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) ~[xercesImpl-2.12.1.jar:?]
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) ~[xercesImpl-2.12.1.jar:?]
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) ~[xercesImpl-2.12.1.jar:?]
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) ~[xercesImpl-2.12.1.jar:?]
at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:439) ~[Saxon-EE-10.6.jar:?]
at net.sf.saxon.event.Sender.send(Sender.java:168) ~[Saxon-EE-10.6.jar:?]
at com.saxonica.ee.jaxp.ValidatorImpl.validate(ValidatorImpl.java:73) ~[Saxon-EE-10.6.jar:?]
at javax.xml.validation.Validator.validate(Validator.java:124) ~[?:1.8.0_301]
[...]
Until this is fixed, we will have to catch SAXExceptions and treat them like validation errors.
Files
Please register to edit this issue