#224 -s option in XQuery is ineffective

v8.0
closed
Michael Kay
7
2012-10-08
2004-06-15
Michael Kay
No

In the XQuery command line interface, the -s option has
no effect unless the -wrap option is also used. Any
attempt in the query to reference the context node will
result in an error.

The problem also affects any Java applications using
the new XQueryExpression#run method to invoke the query.

The source code fix is to add the following lines after
line 186 of XQueryExpression.java (the call on
initializeController()):

    NodeInfo node = env.getContextNode();
    if (node != null) {
        controller.makeContext(node);

controller.setPrincipalSourceDocument(node.getDocumentRoot());
}

Michael Kay

Discussion