A question on the eclipse web tools news group asked about evaluating the current context node in PsychoPath. The Default is for PsychoPath to use the Document as it's context and evaluate from there. There are a couple of ways to evaluate using a given Node as the starting point.
- Create an implementation of the DefaultDynamicContext that takes a NodeType as a parameter instead of just a Document.
- Use an XPath variable and set the value of the variable to the NodeType to begin.
DynamicContext dc = new DefaultDynamicContext(schema, domDoc);
dc.add_namespace("xs", "http://www.w3.org/2001/XMLSchema");
dc.add_namespace("xsd", "http://www.w3.org/2001/XMLSchema");
dc.add_function_library(new FnFunctionLibrary());
dc.add_function_library(new XSCtrLibrary());
ElementType elementType = new ElementType(domDoc.getDocumentElement(), 0);
dc.set_variable(new QName("input-context"), elementType, 0);
This then allows for the XPath expression to be written as:
$input-context/element
The evaluation of the expression will begin with the Document's Root Element instead of at the Document level. You may do this for any node type that you wish evaluation to begin.


OK, I'm a complete XPath2 n00b, but what's with the funny_looking_method_names? Is that a standard binding style for XPath2?
That was inheritted by the original maintainers. PsychoPath was a college project. The method names are just the way they did them instead of doing the standard lowerCamelCase format. Eventually I'll refactor that out, but after getting it full compliant as it will mean breaking some public API.