enhanced the evaluation of global variables to take account of possible
authorWilliam M. Brack <wbrack@src.gnome.org>
Wed, 24 Nov 2004 02:54:35 +0000 (02:54 +0000)
committerWilliam M. Brack <wbrack@src.gnome.org>
Wed, 24 Nov 2004 02:54:35 +0000 (02:54 +0000)
* 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
libxslt/variables.c
libxslt/xsltInternals.h

index 589d941..a104683 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Nov 24 10:51:51 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * 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 <wbrack@mmm.com.hk>
 
        * libxslt/pattern.c: small change to previous fix for bug 153137,
index a6181e7..bcbcc32 100644 (file)
@@ -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);
index 3629b9a..7b6f99a 100644 (file)
@@ -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 */
 };
 
 /*