Added code to in PREDICATE/FILTER handling to reset the xpath context
* xpath.c: Added code to in PREDICATE/FILTER handling to reset
the xpath context document pointer (part of fix to libxslt
bug 147445)
diff --git a/xpath.c b/xpath.c
index eb01145..fd9c694 100644
--- a/xpath.c
+++ b/xpath.c
@@ -10416,6 +10416,7 @@
xmlNodeSetPtr newset = NULL;
xmlNodeSetPtr oldset;
xmlNodePtr oldnode;
+ xmlDocPtr oldDoc;
int i;
/*
@@ -10600,6 +10601,7 @@
oldset = obj->nodesetval;
oldnode = ctxt->context->node;
+ oldDoc = ctxt->context->doc;
ctxt->context->node = NULL;
if ((oldset == NULL) || (oldset->nodeNr == 0)) {
@@ -10621,6 +10623,8 @@
} else {
/*
* Initialize the new set.
+ * Also set the xpath document in case things like
+ * key() evaluation are attempted on the predicate
*/
newset = xmlXPathNodeSetCreate(NULL);
@@ -10630,6 +10634,9 @@
* a single item in the nodeset.
*/
ctxt->context->node = oldset->nodeTab[i];
+ if ((oldset->nodeTab[i]->type != XML_NAMESPACE_DECL) &&
+ (oldset->nodeTab[i]->doc != NULL))
+ ctxt->context->doc = oldset->nodeTab[i]->doc;
tmp = xmlXPathNewNodeSet(ctxt->context->node);
valuePush(ctxt, tmp);
ctxt->context->contextSize = oldset->nodeNr;
@@ -10670,6 +10677,8 @@
ctxt->context->node = NULL;
ctxt->context->contextSize = -1;
ctxt->context->proximityPosition = -1;
+ /* may want to move this past the '}' later */
+ ctxt->context->doc = oldDoc;
valuePush(ctxt, xmlXPathWrapNodeSet(newset));
}
ctxt->context->node = oldnode;