#261 Freestanding XPath fails with variables

v8.1.1
closed
5
2012-10-08
2004-11-03
Michael Kay
No

A NullPointerException or ArrayBoundException occurs
when using the freestanding Java XPath API to execute
XPath expressions that declare variables within the
expression, for example an expression such as

for $i in (10,20) return $i

The exact details depend on which interfaces are used
to evaluate the expression.

Source changes:

In XPathEvaluator, the first five lines of the
createExpression(String) method should read:

public XPathExpressionImpl createExpression(String

expression) throws XPathException {
Expression exp =
ExpressionTool.make(expression, staticContext,0,-1,1);
exp = exp.analyze(staticContext, Type.ITEM_TYPE);
SlotManager map =
staticContext.getConfiguration().makeSlotManager();
ExpressionTool.allocateSlots(exp, 0, map);

In XPathEvaluator, the first five lines of the
evaluate(String) method should read:

public List evaluate(String expression) throws

XPathException {
Expression exp =
ExpressionTool.make(expression, staticContext,0,-1,1);
exp = exp.analyze(staticContext, Type.ITEM_TYPE);
SlotManager map =
staticContext.getConfiguration().makeSlotManager();
ExpressionTool.allocateSlots(exp, 0, map);

In XPathExpression, the evaluate() method should read:

public List evaluate() throws XPathException {
XPathContextMajor context = new
XPathContextMajor(contextNode, config);
context.openStackFrame(stackFrameMap);
SequenceIterator iter =
expression.iterate(context);
SequenceExtent extent = new SequenceExtent(iter);
return (List)extent.convertToJava(Object.class,
config, context);
}

Michael Kay

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks