Re: [xml] Problem with XPath Expression?

On Mon, Apr 09, 2001 at 04:07:01PM +0900, Yuuichi Teranishi wrote:

I think following should cause an syntax error.

% testXPath --expr "false() ABRACADABRA true()"

But it ends normally and returns a value at the error point.

=> Object is a Boolean : false

I don't know the detail of the code, 
but following patch (for latest CVS) seems to fix the problem.

  Well the patch provided is not really the right way to catch this.

----------------- xmlXPathEval( -----------
    if (ctxt->value == NULL) {
                "xmlXPathEval: evaluation failed\n");
        res = NULL;
    } else if (*ctxt->cur != 0) {
        xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_EXPR_ERROR);
        res = NULL;
    } else {
        res = valuePop(ctxt);

  is a far better way IMHO.

orchis:~/XML -> testXPath --expr "false() ABRACADABRA true()"
Error xpath.c:7597: Invalid expression
false() ABRACADABRA true()
Object is empty (NULL)
orchis:~/XML ->

  I fixed xmlXPathCompile to detect it.


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml Gnome XML XSLT toolkit | Rpmfind RPM search engine

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]