#765 Context item in XQuery global variables

v9.0
closed
5
2012-10-08
2008-01-18
Michael Kay
No

This entry concerns two problems relating to the use of global variables ("declare variable") in XQuery, where the initializing expression for the variable depends on the context item set externally for the query.

(The XQuery specification doesn't actually say this is allowed, but the question has been raised and an erratum is expected confirming that it is legal.)

Firstly, if the query is called from the command line, and the main query body does not reference the context item, then Saxon reports that the -s option on the command line was ignored. The source document is not loaded, and evaluation of the variable that requires the context item then fails saying no context item was supplied.

Secondly, when using document projection, the paths computed for the query (which determine which parts of the source document are retained when constructing the tree) do not take into account parts of the source document needed to compute global variables.

A patch fixing these problems is being placed in Subversion.

Discussion

  • Michael Kay

    Michael Kay - 2008-01-18

    Logged In: YES
    user_id=251681
    Originator: YES

    Fixed in 9.0.0.3

     
  • Michael Kay

    Michael Kay - 2008-01-28

    Logged In: YES
    user_id=251681
    Originator: YES

    The patch for this bug (which was incorporated into the 9.0.0.3 build) was unfortunately incorrect; it causes a NullPointerException when document projection is requested for a query that does not use any global variables. A new patch is being placed in Subversion

     
  • Michael Kay

    Michael Kay - 2008-03-17

    Logged In: YES
    user_id=251681
    Originator: YES

    Fixed (again) in 9.0.0.4