Re: [xml] XPath Questions

Date view Thread view Subject view Author view

From: Daniel Veillard (Daniel.Veillard@w3.org)
Date: Thu Feb 03 2000 - 19:02:02 EST


[ Sorry for those who may not be interested in the intricacies of the
  XPath (mis)implementation, maybe I should create a separate list
  for the people more interested in XPath/XSLT. I f I get more
  than 5 responses I will create it, Daniel]

On Thu, Feb 03, 2000 at 05:04:01PM -0800, Art Gillespie wrote:
>
> Hi guys,
>
> Anyone familiar with the status of the XPath implementation in libxml?

 Hum, I'm supposed to :-)

> I'm working on an XSLT implementation, but the expression evaluation
> seems weird. I can't seem to mix path evaluation and the other types of
> expression evaluation. When I use xmlXPathEval(), I just get the path
> information up to the point where I do a comparison. e.g.
>
> //revenue = 5
>
> Returns all of the revenue nodes, and not just the ones where the value
> is 5.

   hum, right :-(

> If I use xmlXPathEvalExpression, I always get an invalid operand error
> with the carat at the last character of the expression.
> I tried running the testXPath executable that comes with libxml and had
> the same results. The shell output is below (This example uses full
> syntax, but I assure you, I tried it with abbreviated syntax as well).
>
>
> [agillesp@cc828112-a libxml-1.8.5]$ ./testXPath
> 'child::chapter[child::title="Chapter 5"]'
> xmlXPathNodeCollectAndTest xpath.c:1858 : nodelist and node are NULL
> xmlXPathNodeCollectAndTest xpath.c:1858 : nodelist and node are NULL
> Error xpath.c:1093: Invalid operand
> child::chapter[child::title="Chapter 5"]
> ^
> xmlXPathEval: 1 object left on the stack
> Object is empty (NULL)
>
>
> So, am I doing something wrong?

No, there is clearly a bug here, I suggest that for debugging you
compiles the xpath module with the debug turned on (#define DEBUG_...
uncommened at the beginning of the xpath.c file). This expression
works:

~/XML -> ./testXPath -i tst3.xml '/child::doc/child::chapter[5=5]'
Basis : computing new set
new step : axis 'child' context contains 1 nodes
           searching for name doc
Testing : doc
Examined 1 nodes, found 1 nodes at that step
Basis : doc
Step : doc
Basis : computing new set
new step : axis 'child' context contains 1 nodes
           searching for name chapter
Testing : chapter chapter chapter chapter
Examined 4 nodes, found 4 nodes at that step
Basis : chapter chapter chapter chapter
After predicate : chapter chapter chapter chapter
Step : chapter chapter chapter chapter
Object is a Node Set :
Set contains 4 nodes:
1 ELEMENT chapter
2 ELEMENT chapter
3 ELEMENT chapter
4 ELEMENT chapter
~/XML ->

 So it seems to fails in the evaluation of the equality operator.
It is described at
   http://www.w3.org/TR/xpath#booleans

paragraph 4 to 7. But the error doesn't seems to be in
the xmlXPathEqualValues but before. Only the string has been pushed on
the stack. It is in the first evalupation of xmlXPathEvalRelationalExpr()

"A location path can be used as an expression. The expression returns
 the set of nodes selected by the path."

 I'm looking at it, it seems I didn't implement correctly the part where
the result of a node collection search is pushed into the stack in the
evaluation, I will try to fix this in the CVS base soon.

  I must admit that some parts of the XPath implementation didn't get
tested much (if any :-\) and I apologize in advance for the set of problems
you may find.

   Daniel

-- 
Daniel.Veillard@w3.org | W3C, INRIA Rhone-Alpes  | Today's Bookmarks :
Tel : +33 476 615 257  | 655, avenue de l'Europe | Linux XML libxml WWW
Fax : +33 476 615 207  | 38330 Montbonnot FRANCE | Gnome rpm2html rpmfind
 http://www.w3.org/People/all#veillard%40w3.org  | RPM badminton Kaffe
----
Message from the list xml@xmlsoft.org
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@xmlsoft.org


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Aug 02 2000 - 12:30:01 EDT