Support #5272
closedXQuery ErrorReporter needs to be set in 3 places
0%
Description
Not sure if this is still the case with Saxon 11.1. In this code:
Processor proc = new Processor(configuration);
proc.getUnderlyingConfiguration().setErrorReporterFactory(config -> {return new ErrorReporterToListener(errorListener);});
proc.setConfigurationProperty(Feature.NAME_POOL, proc.getUnderlyingConfiguration().getNamePool());
proc.setConfigurationProperty(Feature.SOURCE_PARSER_CLASS, CatalogEnabledXMLReader.class.getName());
proc.setConfigurationProperty(Feature.LINE_NUMBERING, Boolean.TRUE);
proc.setConfigurationProperty(Feature.TREE_MODEL, Builder.LINKED_TREE);
// XQuery compiler
XQueryCompiler comp = proc.newXQueryCompiler();
comp.setErrorReporter(new ErrorReporterToListener(errorListener));
comp.setBaseURI(new URI(querySystemID));
XQueryExecutable xPathExecutable = comp.compile(parameter.getValue());
XQueryEvaluator pathSelector = xPathExecutable.load();
pathSelector.setErrorListener(errorListener);
in order to avoid various errors being reported in the console I needed to set the error listener on proc.getUnderlyingConfiguration(), on the XQueryCompiler and on the XQueryEvaluator, otherwise in some stages the errors were dumped to the standard error listener.
Updated by Michael Kay almost 2 years ago
- Category set to Diagnostics
- Status changed from New to Closed
- Assignee set to Michael Kay
Sorry we've allowed this one to fester. I've looked at it a few times to think about whether there's any way we can make progress on it.
XQuery static errors should be reported to the ErrorReporter associated with the XQueryCompiler. Dynamic errors should be reported to the ErrorReporter associated with the XQueryEvaluator. Generally, errors shouldn't find their way to the Configuration's ErrorHandler unless they're not linked to a specific query. I could imagine this happening, for example, if the error is in document building or validation. If you find any such errors, please let us know and we'll see what we can do. In the meantime, I'm afraid there's no particular plan I can think of for identifying such errors.
I'm going to close this tracker now, but if you have any further information that will help us to make progress, please feel free to re-open it.
Please register to edit this issue