GNOME Bugzilla – Bug 334104
xmlXPathEvalExpression: unknown xpath function produces incorrect result
Last modified: 2006-10-17 19:39:49 UTC
Please describe the problem: Given a document: <root><xy/></root> With this: res = xmlXPathEvalExpression("//xy[unknown(.)]", ctxt); you get a nodelist containing 1 "xy" Elelemt as result. The nodelist contains 1 Element, even if there are more than 1 xy nodes in the document. Steps to reproduce: 1. xml doxument: <root><xy/><xy z="a">b</xy></root> 2. res = xmlXPathEvalExpression("//xy[unknown(.)]", ctxt); Actual results: I get a Node set containing 1 Element Expected results: res should be null, as it is with this code comp = xmlXPathCompile(BAD_CAST str); if (comp != NULL) { res = xmlXPathCompiledEval(comp, ctxt); } Does this happen every time? Yes Other information: xmlXPathEvalExpression is used in PHPs dom extension, so the workaround using xmlXPathCompile .... is not an option for me
Adding pctxt->error != XPATH_EXPRESSION_OK in xmlXPathEvalExpression fixes this, and seems not to produce problems, but I'm not sure if this is the right place. if (*pctxt->cur != 0 || pctxt->error != XPATH_EXPRESSION_OK) { xmlXPatherror(pctxt, __FILE__, __LINE__, XPATH_EXPR_ERROR); res = NULL; } else { res = valuePop(pctxt); }
The patch looks right, this makes sense ! Applied and commited, thanks a lot ! Daniel