Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
XPathAPI, or precompiled XPaths
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="David Portabella, post: 2986971"] Hello, I am using XPathAPI class. The problem that I have is that after using XObject object = XPathAPI.eval(node, xpathStr) on 1000 different nodes (same xpathStr), it really becomes very slow. This behavior is indeed documented in the documentation of XPathAPI: [URL]http://xml.apache.org/xalan-j/apidocs/org/apache/xpath/XPathAPI.html[/URL] ++++++ The methods in this class are convenience methods into the low-level XPath API. These functions tend to be a little slow, since a number of objects must be created for each evaluation. A faster way is to precompile the XPaths using the low-level API, and then just use the XPaths over and over. NOTE: In particular, each call to this method will create a new XPathContext, a new DTMManager... and thus a new DTM. That's very safe, since it guarantees that you're always processing against a fully up-to-date view of your document. But it's also portentially very expensive, since you're rebuilding the DTM every time. You should consider using an instance of CachedXPathAPI rather than these static methods. +++++++ The explanation talks about precompiling the XPaths using the low- level API, and then just use the XPaths over and over. How to do this? I would need something like: ++++++++++++ compiledXPath = XXX.compileXPath(xpathStr); .... and then run this for 1000 different nodes: XObject object = compiledXPath.eval(node) ++++++++++++ Do you know how to do this? Regards, DAvid [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
XPathAPI, or precompiled XPaths
Top