[jdom-interest] Maximizing Effeciency of XPATH calls

Jason Hunter jhunter at xquery.com
Fri Sep 9 10:08:55 PDT 2005


I don't know how much data you have, but if it's a lot you can use an 
indexed XQuery engine to do the evaluation (one that indexes what it 
sees during load time and optimizes XPath queries).  MarkLogic's engine 
is free up to 50 Megs (see http://xqzone.marklogic.com for a download 
and http://xqzone.marklogic.com/howto/tutorials/technical-overview.xqy 
for a quick intro).  I'm presently working for Mark Logic on a project 
for a customer with terabytes of XML.

-jh-

Kevin L. Cobb wrote:

> I've recently been tinkering with the effeciency of a process I have to 
> take an XML document and apply a lot of XPATH expressions to the XML.
> Here is what I've done to maximize the effeciency of this process. 
> Hoping others will have other handy tricks up their sleeves or point out any
> glaring deficiency.
>  
> The basic algorithm of the process is this:
> 
>     1. Build a Map of the XPATH's to apply to the XML. The xpath
>     expression is cached as org.jdom.xpath.XPath objects
>     2. For each XML document to apply the Map of xpath expressions to
>         3. Build the Document object from the XML string 
>         4. Loop through the Map of XPath objects and apply each to the
>     message.
>     5 Next XML document
>      
> 
> The things I've done to increase performance are:
> 
>     1. Cached the xpath expressions as org.jdom.xpath.XPath objects
>     2. Ensure the use of the SAXParser, org.apache.xerces.parsers.SAXParser
>     3. Make each xpath expression as effecient as possible. For example,
>     use /*/*/MyElement instead of //MyElement.
>      
>      
>      
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com


More information about the jdom-interest mailing list