wiki:XPATH

Version 8 (modified by heikki, 15 years ago) ( diff )

--

XPATH

author: Heikki Doeleman

This page describes the current ideas about implementing support for XPATH in the ebRIM project.


Introduction

XPATH is a language to precisely select a set of nodes in an XML document. It is also sometimes used to address certain parts of Java object graphs. One of the requirements for the ebRIM project is to support XPATH queries in OGC Filters.

Issue: XPATH on Lucene

It would be straightforward to evaluate XPATH against complete ebRIM documents (domain object graphs). However, we do not have all ebRIM data in memory, therefore we cannot simply evaluate XPATH queries against complete ebRIM documents. This suggests that the best option is to evaluate XPATH queries against the Lucene index. How should we go about doing that ?

A search on Google does not return too many insightful results. One implementation of XPATH against Lucene can be found in the CMS Alfresco, albeit with severe limitations: "does not currently support the attribute axis or predictes".

A hint as to their implementation is the description of Alfresco's Lucene index. It appears as if they use a dedicated field in the index to operate on with XPATH :

#  PATH

    * An XPATH expression used to select nodes
    * This should only be access via a phrase query (ie in "") as it requires special tokenisation

I'm currently looking into their sources to learn more about their implementation, specificaly org.alfresco.util.SearchLanguageConversion.

An exchange on the Solr mailing list point in the same direction (i.e. storing XPATH info in the Lucene index).

Then there's Nux, which also seems to support XPATH on Lucene: "Arbitrary Lucene fulltext queries can be run from Java or from XQuery/XPath/XSLT via a simple extension function." I have no clue yet how they do it, but I'm taking a peek at their source very soon.

Note: See TracWiki for help on using the wiki.