Re: [xml] xpath and the document order
- From: Daniel Veillard <veillard redhat com>
- To: "Oleg A. Paraschenko" <olpa xmlhack ru>
- Cc: xml gnome org, "Liam R. E. Quin" <liam holoweb net>
- Subject: Re: [xml] xpath and the document order
- Date: Sun, 8 May 2005 06:27:36 -0400
On Sun, May 08, 2005 at 12:11:58AM +0400, Oleg A. Paraschenko wrote:
I tried different combinations, but failed and gave up. Maybe it's
because I don't believe that I can find an example. As far as I know,
a result nodeset shouldn't contain duplicates. One of the simplest
yes that is garanteed.
methods to find duplicates is to sort the nodeset, and I suspect that
"xmlXPathEvalExpression" does sort it.
Duplicates are eleminated when growing the node set.
But maybe I just use an incorrect code to test. Here it is:
xpath = '/warning//text()'
You can use testXPath to see how this is compiled:
paphio:~/XML -> ./testXPath --tree '/warning//text()'
Compiled Expression : 5 elements
SORT
COLLECT 'child' 'type' 'text' text
COLLECT 'descendant-or-self' 'type' 'node'
COLLECT 'child' 'name' 'node' warning
ROOT
by default the XPath compiler adds a sorting step. So it seems
you were right, xmlXPathEvalExpression will order the output at least
in that case. One way to force ordering at the XPath level is to
put the XPath expression between curly braces: "(your_xpath_here)"
Daniel
--
Daniel Veillard | Red Hat Desktop team http://redhat.com/
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]