>Evaluating Context Node in PsychoPath

>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.

  1. Create an implementation of the DefaultDynamicContext that takes a NodeType as a parameter instead of just a Document.
  2. Use an XPath variable and set the value of the variable to the NodeType to begin.

The latter is much quicker to setup and can be setup like the following:

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:


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.

This entry was posted in eclipse, xml, xpath. Bookmark the permalink.

2 Responses to >Evaluating Context Node in PsychoPath

  1. Jesper says:

    >OK, I’m a complete XPath2 n00b, but what’s with the funny_looking_method_names? Is that a standard binding style for XPath2?

  2. David Carver says:

    >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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s