[jdom-interest] Maximizing Effeciency of XPATH calls

Kevin L. Cobb kevin.cobb at emergint.com
Fri Sep 9 05:56:55 PDT 2005

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
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
	    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,
	3. Make each xpath expression as effecient as possible. For
example, use /*/*/MyElement instead of //MyElement. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20050909/2becaaf2/attachment.htm

More information about the jdom-interest mailing list