[jdom-interest] Prepping JDOM 2.4 - question about XPath API

Rolf Lear jdom at tuis.net
Sun Oct 28 14:37:24 PDT 2012


Hi all.

I have been working on a Saxon interface layer for the past few weeks... 
and I realized that there is the option of adding support for a 
library-specific 'index' for calculating XPaths.

For example, Saxon builds an 'index' in to the document which it then 
uses to 'accelerate' the XPath queries. If an index is built once, and 
then reused multiple times, it can improve the performance of the XPath 
evaluation quite significantly (in my testing, it can 'halve' the 
evaluation time.

I have played with various scenarios, but I think the best way to 
support 'indexes' is to incorporate them at the 'Factory' level. Thus, 
add the following:

new method: StaticIndex XPathFactory.buildIndex(Object)
this method will build a 'StaticInstance' instance which contains the 
information needed by the factory to have a static 'index' in to the
document or node.

org.jdom2.xpath.StaticIndex - a class containing whatever the factory 
wants....

add versions of the methods evaluate(...), evaluateFirst(...), and 
diagnose(...) which take a StaticIndex argument in addition to the context.



I know this is a fair bit of detail for people not necessarily familiar 
with the code, but the consequence of this change would be that if 
someone has already extended the XPath API with their own implementation 
(which I don't think anyone has done), they will need to make code 
changes because the underlying API will change a bit.

It will also mean that people who wrote code against JDOM 2.4 will not 
be able to run with JDOM 2.3 or older.

I don't believe any of this will be a problem, but I thought I would get 
some input before I commit....

I have submitted Issue 99 to track:

https://github.com/hunterhacker/jdom/issues/99

Rolf


More information about the jdom-interest mailing list