Project

Profile

Help

Bug #1166

closed

Schema-aware XPath using JAXP API

Added by Anonymous almost 15 years ago. Updated over 12 years ago.

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

0%

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

Description

SourceForge user: mhkay

Saxon's implementation of the JAXP API is not working correctly with schema-aware expressions.

(Note, this interface is not recommended for schema-aware XPath processing: the JAXP API is designed primarily for XPath 1.0, and it cannot be used in a portable way with XPath 2.0 as it does not support features like schema-awareness. The s9api interface is recommended instead. Nevertheless, this interface is supported, and bugs will be fixed.)

In Saxon 9.2, schema-awareness is a property of an excecutable, and should be enabled by default if a schema is imported into the static context. When the method XPathEvaluator.importSchema() is called, therefore, the executable should be marked as schema-aware, but this is not happening. In consequence, the XPath compiler makes incorrect static type inferences, typically assuming that data will be untyped when it is not, and this may result in spurious compile-time type errors, or in incorrect code being generated which might for example crash at runtime with a ClassCastException.

A patch is being applied, in the 9.2 branch only, to module JAXPXPathStaticContext.

This problem prevents the sample application XPathExampleSA from working. There are other problems with this sample application, and a new version is therefore being provided as an attachment to this bug entry. These problems are:

(1) the program tests xpf.getFeature("http://saxon.sf.net/feature/schema-validation") to determine if the processor is schema-aware. However, this is the wrong test. The test fails, because it is actually checking whether strict schema validation has been requested (which it has not).

(2) the program issues a query which, when used with the sample books.xml data file, selects no data and therefore returns an empty result. This is because the query is written to find books published in the 12 months before the current data, and there are no such books in the sample data.

(3) when this problem is corrected, the expression calls a user-defined extension function. The calling conventions for user-defined functions in the JAXP XPath interface are not well defined, either in the JAXP documentation or in the Saxon documentation. This function is expecting the arguments to be supplied in a different format from that actually provided. I will do further work to clarify the rules here.


Files

XPathExampleSA.java (9.56 KB) XPathExampleSA.java Anonymous, 2009-12-02 11:38
Actions #1

Updated by Anonymous almost 15 years ago

SourceForge user: mhkay

The same problem affects the s9api XPathCompiler object. A further patch is being raised to ensure that calling XPathCompiler.importSchemaNamespace() has the side-effect of marking the underlying Executable as schema-aware.

Actions #2

Updated by Anonymous almost 15 years ago

SourceForge user: mhkay

Fixed in 9.2.0.5

Please register to edit this issue

Also available in: Atom PDF