Travis,
one of our members, Michael, gave me some hint that there are a number of cases when the getNode() method is in fact faster than getItemAsString(null). This is due to the fact that the latter method triggers the complete serialization process, which can be overhead in some cases.
So, in a nutshell, it depends on what you plan to do with the results. If you prefer to directly process the atomized string of XML nodes, I'd recommend to either extend your XQuery and use getAtomicValue()…
String query = "for $i in /your/query return string($i)" ... String result = xqitem.getAtomicValue();
..or run the latest version from the repository, which includes additional optimizations on the getItemAsString() method.
If you want to further process DOM nodes, you might need to perform some additional tests on your own; it seems there is no simple answer.
Christian ___________________________
On Tue, Mar 23, 2010 at 11:59 AM, Christian Grün christian.gruen@gmail.com wrote:
Dear Travis,
in BaseX, we use an internal representation that differs from DOM. If DOM instances are requested, they will be created on-the-fly. This is why I generally recommend to avoid the getNode() method and rather use getItemAsString(), which is pretty slim, as it simply serializes the contents of an item:
Feel free to ask for more, Christian
On Tue, Mar 23, 2010 at 5:52 AM, Travis Webb tjwebb@vt.edu wrote:
I have a question regarding efficiency in the xqresultsequence in the XQJ API. I've found no documentation on how this object is actually represented. Does anyone know if it is faster to request the result as a string (getItemAsString(null)) or as a DOM node (getNode())? Any info is appreciated. Thanks. -tjw
Christian Gruen Universitaet Konstanz Department of Computer & Information Science D-78457 Konstanz, Germany Tel: +49 (0)7531/88-4449, Fax: +49 (0)7531/88-3577 http://www.inf.uni-konstanz.de/~gruen