Re: [xml] proximity position in libxml2's xmlXPathEvalExpression()
- From: Daniel Veillard <veillard redhat com>
- To: Marius Konitzer <m konitzer gmx de>
- Cc: xml gnome org
- Subject: Re: [xml] proximity position in libxml2's xmlXPathEvalExpression()
- Date: Wed, 18 Oct 2006 17:26:21 -0400
On Wed, Oct 18, 2006 at 11:14:18PM +0200, Marius Konitzer wrote:
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.
Don't hesitate to call me a fool for this stupid-looking question, I
probably just got something terribly wrong, right?
Not really, seems you hit a bug when element are not pre-ordered.
Please create a bugzilla for this, I guess it's limited to comments
(and possibly PIs)
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.
Daniel
--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]