javaxmlxpathvtd-xmlxom

Time and memory efficient java XPath parser


What I need is a java implementation of XPath parser that will be more intuitive to use and comparable in memory and time efficiency to VTD-XML. What is more, I need it to perform nested Xpath expressions for some additional performance gains.

In my current project I do a lot of XPath parsing with VTD-XML which is really fast and memory efficient, but really difficult to learn and with convoluted syntax.

I looked at XOM and Xalan parsers already. Xalan has a poor performance comparing to VTD. XOM on the other hand is a good one but as far as I know it lacks the feature of nesting XPath expressions. By nested expressions I mean the possibility to execute XPath search from some position in document and not always from the beginning.

Thanks for any answers.


Solution

  • I do not think you will be able to easily find a replacement of VTD-XML for fast XPath and memory saving. The fundamental reason is that every little object allocation (think element nodes, strings, attributes, etc ) incurs a little bit memory overhead, and those overheads tend to accumulate during the construction of a DOM tree, leading to significant memory overhead as observed in object based XML modeling APIs such as DOM.

    As VTD-XML's underlying modeling approach is different from DOM, its style of API differs drastically from DOM API as well. So if you are accustomed to DOM, there will be some learning curves (which is to be expected)...

    If you use VTD-XML in ways that it is not intended to be used, your code certainly will be convoluted and ugly. Ignore the underlying principle of reducing/eliminating object creation, and your app will end up being sluggish. No tools in this world can help you.