- testXPath.c xpath.c: fixing the XPath union expressions problem
  reported by  Martin Vidner <martin@artax.karlin.mff.cuni.cz>
Daniel
diff --git a/ChangeLog b/ChangeLog
index ac85c8c..fed3ad3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Jan  3 16:19:39 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+	* testXPath.c xpath.c: fixing the XPath union expressions problem
+	  reported by  Martin Vidner <martin@artax.karlin.mff.cuni.cz>
+
 Wed Jan  3 14:22:33 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
 	* xmllint.c: Made is so if the file name is "-" is will read form
diff --git a/testXPath.c b/testXPath.c
index bca7173..2bd5eb5 100644
--- a/testXPath.c
+++ b/testXPath.c
@@ -98,6 +98,7 @@
     } else {
 #endif
 	ctxt = xmlXPathNewContext(document);
+	ctxt->node = xmlDocGetRootElement(document);
 	if (expr)
 	    res = xmlXPathEvalExpression(BAD_CAST str, ctxt);
 	else
diff --git a/xpath.c b/xpath.c
index d667bbb..d87318c 100644
--- a/xpath.c
+++ b/xpath.c
@@ -4730,12 +4730,13 @@
     xmlXPathEvalPathExpr(ctxt);
     CHECK_ERROR;
     SKIP_BLANKS;
-    if (CUR == '|') {
-	xmlXPathObjectPtr obj1,obj2;
+    while (CUR == '|') {
+	xmlXPathObjectPtr obj1,obj2, tmp;
 
 	CHECK_TYPE(XPATH_NODESET);
 	obj1 = valuePop(ctxt);
-	valuePush(ctxt, xmlXPathNewNodeSet(ctxt->context->node));
+	tmp = xmlXPathNewNodeSet(ctxt->context->node);
+	valuePush(ctxt, tmp);
 
 	NEXT;
 	SKIP_BLANKS;
@@ -4745,6 +4746,10 @@
 	obj2 = valuePop(ctxt);
 	obj1->nodesetval = xmlXPathNodeSetMerge(obj1->nodesetval,
 		                                obj2->nodesetval);
+	if (ctxt->value == tmp) {
+	    tmp = valuePop(ctxt);
+	    xmlXPathFreeObject(tmp);
+	}
 	valuePush(ctxt, obj1);
 	xmlXPathFreeObject(obj2);
 	SKIP_BLANKS;