I have a java objects tree structure (model) created using java Lists and Maps, and I want to evaluate an xpath of the following sort:
name[/type='theType']
This xpath expression needs both the context node and the root node. However, I've found no way how to pass both nodes to JXPath for evaluation. I've tried several variants of the following code (tried to exchange root and context, null instead of rootContext etc.):
JXPathContext rootContext = JXPathContext.newContext(rootNode);
JXPathContext contextContext = JXPathContext.newContext(rootContext, contextNode);
Pointer p = contextContext.getPointer(xpath);
return p.getNode();
but none worked. In contrast to a XML DOM model, in containers you have no direct access from a context node to the root node.
Would you have any advice on how to do that?