Project

Profile

Help

SaxonEE 9.7 Validate throwing an XPathException

Added by Jason Callister over 6 years ago

The Processor is throwing an exception, for reasons we understand. Is there Saxonica configuration to log this exception as a validation error, rather than throwing the actual application itself?

If not, we can catch this exception and i'm curious to hear how to create a new StaticError for the collection.


{"org.xml.sax.SAXParseException; systemId: file:///D:/PATHTOXSD.xsd; lineNumber: 74; columnNumber: 31; The prefix \"crs\" for element \"crs:SubstantialOwner\" is not bound."}
    Data (System.Exception): {System.Collections.ListDictionaryInternal}
    Data: {System.Collections.ListDictionaryInternal}
    HResult: -2146233088
    HelpLink (System.Exception): null
    HelpLink: null
    InnerException (System.Exception): null
    InnerException: null
    Message (System.Exception): "org.xml.sax.SAXParseException; systemId: file:///D:/PATHTOXSD.xsd; lineNumber: 74; columnNumber: 31; The prefix \"crs\" for element \"crs:SubstantialOwner\" is not bound."
    Message: "org.xml.sax.SAXParseException; systemId: file:///D:/PATHTOXSD.xsd; lineNumber: 74; columnNumber: 31; The prefix \"crs\" for element \"crs:SubstantialOwner\" is not bound."
    Source (System.Exception): "saxon9ee"
    Source: "saxon9ee"
    StackTrace (System.Exception): "   at net.sf.saxon.event.Sender.sendSAXSource(SAXSource , Receiver , ParseOptions )\r\n   at net.sf.saxon.event.Sender.send(Source source, Receiver receiver, ParseOptions options)\r\n   at Saxon.Api.SchemaValidator.Run()\r\n   at IOMG.OnlineServices.IncomeTax.Ips.Messages.Validation.SaxonicaValidator.Validate(Stream Input, Xsd Schema) in D:\PATHTOCLASS\\SaxonicaValidator.cs:line 36"
    StackTrace: "   at net.sf.saxon.event.Sender.sendSAXSource(SAXSource , Receiver , ParseOptions )\r\n   at net.sf.saxon.event.Sender.send(Source source, Receiver receiver, ParseOptions options)\r\n   at Saxon.Api.SchemaValidator.Run()\r\n   at IOMG.OnlineServices.IncomeTax.Ips.Messages.Validation.SaxonicaValidator.Validate(Stream Input, Xsd Schema) in D:\\PATHTOCLASS\\SaxonicaValidator.cs:line 36"
    TargetSite (System.Exception): {Void sendSAXSource(javax.xml.transform.sax.SAXSource, net.sf.saxon.event.Receiver, net.sf.saxon.lib.ParseOptions)}
    TargetSite: {Void sendSAXSource(javax.xml.transform.sax.SAXSource, net.sf.saxon.event.Receiver, net.sf.saxon.lib.ParseOptions)}


Replies (4)

Please register to reply

RE: SaxonEE 9.7 Validate throwing an XPathException - Added by Jason Callister over 6 years ago

Note:

http://www.saxonica.com/documentation/index.html#!changes/dotnet/9.2-9.3 The error handling in the XPath API has been improved so that static and dynamic errors occurring during XPath evaluation now result in a Saxon.Api.StaticError or Saxon.Api.DynamicError being thrown, rather than exposing the underlying Java exceptions.

RE: SaxonEE 9.7 Validate throwing an XPathException - Added by Michael Kay over 6 years ago

The exception is a (namespace) well-formedness error rather than a validation error, and as such, it is detected by the XML parser rather than by the XSD validator. XML parsers generally terminate on the first well-formedness error found, even though a few errors (like this one) would be fairly easy to recover from. But Saxon has very little control over the XML parser, so there's limited scope.

You can of course write a SAX ErrorHandler to receive notification of such errors, but I don't think there is any way to ask the SAX parser to continue parsing after reporting the error.

RE: SaxonEE 9.7 Validate throwing an XPathException - Added by Jason Callister over 6 years ago

Thanks Michael, do you have any documentation around writing a Sax ErrorHandler? Or any examples?

RE: SaxonEE 9.7 Validate throwing an XPathException - Added by Michael Kay over 6 years ago

Elliotte Rusty Harold's book "Processing XML with Java" is an excellent resource for such things.

    (1-4/4)

    Please register to reply