#377 XPath API on DOM returns wrapper nodes

v8.5
closed
5
2012-10-08
2005-08-03
Michael Kay
No

When using the JAXP XPath API to select within a DOM,
the method

evaluate(expression, DOMNode, XPathConstants.NODE)

returns the Saxon wrapper for the DOM node, not the DOM
node itself.

The same problem may well apply to JDOM and XOM input
sources.

Source fix:

In net.sf.saxon.xpath.XPathExpressionImpl at line 243,
change

            while (true) {
                Item first = iter.next();
                if (first == null || first

instanceof NodeInfo) {
return first;
}
throw new
XPathExpressionException("Expression result is not a
node");
}

to

            while (true) {
                Item first = iter.next();
                if (first instanceof VirtualNode) {
                    return

((VirtualNode)first).getUnderlyingNode();
}
if (first == null || first
instanceof NodeInfo) {
return first;
}
throw new
XPathExpressionException("Expression result is not a
node");
}

(Come to think of it, the "while (true)" here is
completely redundant; but it's not actually wrong!)

New in Saxon 8.5.

Discussion

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

Sign up for the SourceForge newsletter:





No, thanks