From 38c93a398f80f5dde5100299f02c5b0fcb680bb6 Mon Sep 17 00:00:00 2001 From: "William M. Brack" Date: Wed, 24 Nov 2004 02:54:35 +0000 Subject: enhanced the evaluation of global variables to take account of possible * libxslt/variables.c, libxslt/xsltInternals.h: enhanced the evaluation of global variables to take account of possible changes to the current document (bug 158372). --- ChangeLog | 6 ++++++ libxslt/variables.c | 10 +++++++++- libxslt/xsltInternals.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 589d9415..a1046837 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Nov 24 10:51:51 HKT 2004 William Brack + + * libxslt/variables.c, libxslt/xsltInternals.h: enhanced the + evaluation of global variables to take account of possible + changes to the current document (bug 158372). + Mon Nov 22 08:10:18 HKT 2004 William Brack * libxslt/pattern.c: small change to previous fix for bug 153137, diff --git a/libxslt/variables.c b/libxslt/variables.c index a6181e7c..bcbcc322 100644 --- a/libxslt/variables.c +++ b/libxslt/variables.c @@ -570,7 +570,8 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt) { if ((ctxt == NULL) || (elem == NULL)) return(NULL); - if (elem->computed) + /* For pre-computation, need to correlate with the current document */ + if ((elem->computed) && (elem->doc == ctxt->xpathCtxt->doc)) return(elem->value); @@ -579,6 +580,12 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt) { "Evaluating global variable %s\n", elem->name)); #endif + /* If document has changed, destroy the old value */ + if (elem->value != NULL) { + xmlXPathFreeObject(elem->value); + elem->value = NULL; + } + #ifdef WITH_DEBUGGER if ((ctxt->debugStatus != XSLT_DEBUG_NONE) && elem->comp && elem->comp->inst) @@ -687,6 +694,7 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt) { if (result != NULL) { elem->value = result; elem->computed = 1; + elem->doc = ctxt->xpathCtxt->doc; } elem->name = name; return(result); diff --git a/libxslt/xsltInternals.h b/libxslt/xsltInternals.h index 3629b9a9..7b6f99a8 100644 --- a/libxslt/xsltInternals.h +++ b/libxslt/xsltInternals.h @@ -311,6 +311,7 @@ struct _xsltStackElem { const xmlChar *select; /* the eval string */ xmlNodePtr tree; /* the tree if no eval string or the location */ xmlXPathObjectPtr value; /* The value if computed */ + xmlDocPtr doc; /* The document used to compute the value */ }; /* -- cgit v1.2.3