After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 334104 - xmlXPathEvalExpression: unknown xpath function produces incorrect result
xmlXPathEvalExpression: unknown xpath function produces incorrect result
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
2.6.x
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-03-10 09:13 UTC by Olaf Walkowiak
Modified: 2006-10-17 19:39 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Olaf Walkowiak 2006-03-10 09:13:21 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
Comment 1 Olaf Walkowiak 2006-03-10 09:20:15 UTC
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);
    }
Comment 2 Daniel Veillard 2006-10-17 19:39:49 UTC
The patch looks right, this makes sense !

 Applied and commited, thanks a lot !

Daniel