Project

Profile

Help

Bug #2711

closed

UnsupportedOperationException when compiling XPath with JAXP NamespaceContext

Added by Gunther Rademacher about 8 years ago. Updated almost 8 years ago.

Status:
Closed
Priority:
Normal
Category:
JAXP Java API
Sprint/Milestone:
Start date:
2016-04-14
Due date:
% Done:

100%

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

Description

While upgrading to Saxon-EE 9.7, I found that this code snippet now throws an UnsupportedOperationException:

        XPath xpath = new XPathFactoryImpl().newXPath();
        xpath.setNamespaceContext(namespaceContext);
        xpath.compile("//*:x");

where namespaceContext is a javax.xml.namespace.NamespaceContext.

Here is a stack trace:

Exception in thread "main" java.lang.UnsupportedOperationException
	at net.sf.saxon.xpath.JAXPXPathStaticContext.iteratePrefixes(JAXPXPathStaticContext.java:165)
	at net.sf.saxon.expr.parser.RetainedStaticContext.<init>(RetainedStaticContext.java:85)
	at net.sf.saxon.sxpath.AbstractStaticContext.makeRetainedStaticContext(AbstractStaticContext.java:109)
	at net.sf.saxon.expr.parser.XPathParser.parse(XPathParser.java:472)
	at net.sf.saxon.expr.parser.ExpressionTool.make(ExpressionTool.java:99)
	at net.sf.saxon.xpath.XPathEvaluator.compile(XPathEvaluator.java:194)

A complete program reproducing this is attached.


Files

XPathCompile.java (1.59 KB) XPathCompile.java reproduction of 9.7 UnsupportedOperationException Gunther Rademacher, 2016-04-14 15:38
Actions #1

Updated by Michael Kay about 8 years ago

Thanks. The fact that you can't discover/enumerate all the namespace bindings in a JAXP NamespaceContext is one of the lousiest "features" of this lousy API, but I thought we had found a way around it. Will look into it.

Actions #2

Updated by Michael Kay about 8 years ago

  • Category set to JAXP Java API
  • Status changed from New to In Progress
  • Assignee set to O'Neil Delpratt

Indeed the code contains an ingenious workaround for the JAXP NamespaceContext problem, but the workaround turns out to be inactive because it was accidentally disabled by preprocessor tags added in order to make the .NET build work. (See RetainedStaticContext.JAXPStaticContextCheck). Unfortunately most of our unit testing is done in a development environment where this doesn't show up as a problem, and we didn't have any tests on the final production build that revealed the issue.

Actions #3

Updated by O'Neil Delpratt about 8 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 100
  • Fix Committed on Branch 9.7 added

Bug fixed by removing the preprocessor directives. Committed to subversion on the 9.7 and the development branches.

Actions #4

Updated by O'Neil Delpratt almost 8 years ago

This fix has caused problems in the .NET build. I have refactored the fix into a method on the Platform. This allows us to do different things on the Java and on .NET.

Actions #5

Updated by O'Neil Delpratt almost 8 years ago

  • Status changed from Resolved to Closed
  • Fixed in Maintenance Release 9.7.0.5 added

Bug fix applied in the Saxon 9.7.0.5 maintenance release.

Actions #6

Updated by O'Neil Delpratt almost 8 years ago

  • Sprint/Milestone set to 9.7.0.5

Please register to edit this issue

Also available in: Atom PDF