#60 Unions in freestanding XPath

v6.5
closed
Michael Kay
5
2012-10-08
2002-02-06
Michael Kay
No

This problem only affects Java applications using
Saxon to process XPath expressions directly, without
an XSLT stylesheet.

A NullPointerException occurs if you try to evaluate a
Union expression (e.g. a|b) from a Java application
using a Context object that does not refer to any
Controller. In fact the problem is more general than
this: a Controller is needed for two classes of
expresssion:

(a) those that use XSLT-specific functions (such as
key() or format-number()
(b) those that require sorting of nodes, potentially
from multiple documents, into document order.

Expressions in the first group should fail cleanly if
called in a free-standing environment without a
stylesheet. Expressions in the second group should
work, but at present they work only if the documents
concerned are present in a document pool owned by a
Controller.

Present in 6.5, 7.0, and all earlier releases.
Reported by Yves Bekkers [yves.bekkers@irisa.fr]

Discussion

  • Michael Kay
    Michael Kay
    2002-02-06

    Logged In: YES
    user_id=251681

    I have done a source fix in the 6.5 code branch; it's not a
    complete solution. It ensures that whenever a Context
    object is created, there will be a Controller available; if
    no Controller is supplied explicitly, then a default system-
    wide Controller is used. This works except when multi-
    threading: if multiple threads are created, it is essential
    for the application to create a Controller explicitly (and
    not share it between threads). Part of the solution is that
    when document trees are built without reference to a
    controller, any attempt to compare nodes in those trees to
    sort them into document order now automatically registers
    the trees in the DocumentPool managed by the Controller.

    Not yet fixed in the 7.0 code branch, where I hope to
    provide a more radical solution.

     
  • Michael Kay
    Michael Kay
    2002-02-20

    Logged In: YES
    user_id=251681

    Cleared in 6.5.1. Still present in 7.0 (and source changes
    not yet applied to the 7.0 branch).

     
  • Michael Kay
    Michael Kay
    2002-04-30

    Logged In: YES
    user_id=251681

    Fixed in 7.1