Project

Profile

Help

Bug #2356

closed

XPathExpressionImpl always logs to System.err

Added by Mark Holster about 9 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Diagnostics
Sprint/Milestone:
Start date:
2015-04-10
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.6
Fix Committed on Branch:
9.6
Fixed in Maintenance Release:
Platforms:

Description

Hi,

When evaluating a xpath expression against an InputSource the parse errors are always logged to the System.err stream. This is caused because the errorListener isn't copied from the Configuration instance in the net.sf.saxon.lib.ParseOptions.applyDefaults(Configuration) method. Although the javadoc of that method suggests the settings of the Configuration instance are copied to the ParseOptions instance, this will never be the case for the errorListener. The errorListener from the ParseOptions instance is copied to itself at this moment.

Kind regards,

Mark

Actions #1

Updated by Michael Kay almost 9 years ago

  • Category set to Diagnostics
  • Status changed from New to In Progress

I've done a few experiments and come to the conclusion that I need to see more precisely what you are actually doing. E.g. is it a static error or a dynamic error? In my experiments, the errors don't actually get notified to any ErrorListener, they simply get thrown back to the application as an exception - which I suspect is the way it should be.

Actions #2

Updated by Mark Holster almost 9 years ago

Hi Michael,

This is the simplified code I use:

Configuration config = new Configuration();
XPathFactory xpf = new XPathFactoryImpl(config);
XPath xPath = xpf.newXPath();
XPathExpression compiledExpression = xPath.compile("/*");
try {
	compiledExpression.evaluate(new InputSource(new StringReader("This is invalid xml")));
} catch (Exception e) {
// No-op for demonstration purposes.
}

No matter a custom errorListeren is set on the config object or not, the error will always be printed on the System.out. This is because copying the errorListener in net.sf.saxon.lib.ParseOptions.applyDefaults(Configuration) fails. I'm using saxon-he-9.0.6-5. You are right, the exception are thrown back to the application, but there's also some logging to the System.out.

Kind regards,

Mark

Actions #3

Updated by Michael Kay almost 9 years ago

OK, thanks. I hadn't realised we were talking about XML parsing errors.

Actions #4

Updated by Michael Kay almost 9 years ago

  • Status changed from In Progress to Resolved
  • Assignee set to Michael Kay

A patch has been committed on the 9.6 and 9.7 branches so that parseOptions.applyDefaults() picks up the ErrorListener from the Configuration as intended.

I will also improve the Javadoc for relevant interfaces to indicate that a user-defined ErrorListener can be invoked. Note that there is no hint of this in JAXP documentation.

Actions #5

Updated by O'Neil Delpratt almost 9 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in version set to 9.6.0.6

Bug fix applied in the Saxon 9.6.0.6 maintenance release.

Actions #6

Updated by O'Neil Delpratt over 8 years ago

  • Sprint/Milestone set to 9.6.0.6
  • Applies to branch 9.6 added
  • Fix Committed on Branch 9.6 added
  • Fixed in Maintenance Release 9.6.0.6 added

Please register to edit this issue

Also available in: Atom PDF