GNOME Bugzilla – Bug 363252
proximity position in libxml2's xmlXPathEvalExpression()
Last modified: 2006-11-18 16:42:47 UTC
Consider the following XML document: <test><!-- a --><somenode><!-- b --></somenode><!-- c --></test> and let libxml2 evaluate the XPath expression "//comment()" on it. libxml2 returns node-set (a,c,b) instead of (a,b,c), that I would have expected. To be exact, "(//comment())[2]" gives singleton (c) instead of the expected (b). W3C's XPath recommendation indeed states, that predicates are to determine "the position of the node in the node-set ordered in document order if the axis is a forward axis" [1], which should be the case here. On Wed, 2006-10-18 at 17:26 -0400, Daniel Veillard wrote: > There is a good workaround, call xmlXPathOrderDocElems() on your > document before running XPath queries on it, that fixes it and will > speed up some XPath operations a lot. Confirmed, that works for the time being. Thanks! Marius
This problem was introduced around last May, when some coding to speed up node list comparisons was implemented. I have made a small enhancement which I believe should fix it (it certainly fixes the test case). Please try the current CVS code on your original data, and re-open the bug if there are any further problems. Thanks for the clear information which you provided!