[jdom-interest] newbie question

bob mcwhirter bob at werken.com
Wed Dec 4 07:06:03 PST 2002

> I agree that XPath is probably not the fastest (CPU-wise) solution but why do 
> you think XPath can lead to memory problems?
> The XPath engine allocates memory when it compiles the XPath expression (when 
> you invoke XPath.newInstance) but not when evaluating the expression against a 
> given node. At this stage, it just navigates the document.
> There's one exception to the above rule in Jaxen: Namespaces. When evaluating 
> namespaces, the XPath engine allocates wrapper objects as XPath Namespaces do 
> have a parent while JDOM's don't.
> As for speed, you can reach quite good performances by compiling XPath 
> expressions and reusing them (i.e. using XPath.newInstance rather than the 
> static selectNodes and selectSingleNode). If need be, you can use XPath 
> variables in your expressions to use few generic compiled XPaths and call 
> setVariable to "adapt" the expression before each evaluation.

Also, fwiw, I've got changes in the pipe-line, so that when evaluating
the XPath, you can pass a VariableContext into the method, allowing for
multi-threadsafe evaluation of an XPath with simultaneous different
variable bindings.  Not in jaxen yet, but soon.  Was just an oversight.


More information about the jdom-interest mailing list