[jdom-interest] Maximizing Effeciency of XPATH calls

Laurent Bihanic laurent.bihanic at atosorigin.com
Fri Sep 9 07:27:36 PDT 2005


> 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. 

SAXBuilder can reuse the parser instance (it does by default) when invoked several times. Thus by reusing the SAXBuilder object for multiple parses you also save the parser allocation time.
If you validate against schemas, you should also activate Xerces grammar cache so that schemas will be parsed only once. This saves a loooooot of time since shemas are sometimes bigger than the documents themselves.


More information about the jdom-interest mailing list