From Eclipsepedia

< PsychoPathXPathProcessor
Revision as of 19:46, 26 April 2011 by (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


XPath2 "Loki" Requirements and Development

The working name for Version 2.0 and the further work ahead on the XPath 2.0 Processor is Loki.   Loki being one the more mischievous beings fits right in with the overall PsychoPath mentality.   This page is to capture design requirements for PsychoPath 2.0 as implemented for WTP 3.3 and datail the future enhancements planned ahead.


Version 2.0 should feature an API which is separated from the internal implementation and stable when it comes to extensions, and should not include direct references to internal Xerces classes. This requires a major rework to keep the types derived from AnyType invisible from the API classes, and requires a different type system.

A new TypeProvider API has been introduces to decouple the XPath2 engine from Xerces, but providing Xerces type information by default. In addition, a "best effort" type provider has been implemented against the WTP SSE-based XML editor, for use in the Eclipse XPath view.

General Refactorings

The current dynamic engine is exposed as the class Engine, which can generate a XPath2 expression which is in turn evaluated directly.

In the future, different implementations (e.g. one with static checking, or one with byte-code generation, etc) may be introduced but follow the same API pattern.

Type Libraries

A notion of a Type Library has been introduced to hide the internals of the AnyType hierarchy and keep the API clean. The BuiltinTypeLibrary provides access to instantiating the AnyType classes. The TypeDefinition and ItemType interfaces have been introduced to reify the type information previously only available in the AnyType hierarchy.


The old API required all function libraries to keep a reference to the dynamic and static contexts. This was removed, by using an EvaluationContext which is passed into the functions, holding both the static and dynamic contexts, and also the current focus information.

The default implementations of the static and dynamic contexts used to be tightly coupled, which precluded re-entrant use across threads. With 2.0, this is changed so that the StaticContext is used only when parsing (and handling static names), and is remembered by the expression (encapsulated in the XPath2Expression created by Engine). Whenever the expression is evaluated, a DynamicContext must then be instantiated (or re-used), at the discretion of the consumer.

ResultSequences are now immutable, which matches the immutability of the AnyType hierarchy - an AnyType instance is now also a ResultSequence. Thus, the result of "concatenate('a', 'b', 'c')" is now just a single object, XSString("abc"), replacing the more general quartet of DefaultResultSequence, holding an ArrayList, holding an array, pointing to the XSString. Since the AnyType hierarchy is marked 'internal', this should not bother anyone.

We hope this change will enable to consumer to cache expressions (and thus static contexts) enabling more efficient use of memory and less parsing and analysis.


Since Apache Xerces 2.10 beta is using the PsychoPath libraries, the main compatibility has been retained.