diff options
author | William M. Brack <wbrack@src.gnome.org> | 2004-11-24 02:54:35 +0000 |
---|---|---|
committer | William M. Brack <wbrack@src.gnome.org> | 2004-11-24 02:54:35 +0000 |
commit | 38c93a398f80f5dde5100299f02c5b0fcb680bb6 (patch) | |
tree | aa72aa6204a58c7c5a9347185cbaed1ecfc40b67 | |
parent | 15828d4cde05a61835f0d9306e0d35769489bdc4 (diff) | |
download | libxslt-38c93a398f80f5dde5100299f02c5b0fcb680bb6.tar.gz libxslt-38c93a398f80f5dde5100299f02c5b0fcb680bb6.tar.bz2 libxslt-38c93a398f80f5dde5100299f02c5b0fcb680bb6.zip |
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).
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | libxslt/variables.c | 10 | ||||
-rw-r--r-- | libxslt/xsltInternals.h | 1 |
3 files changed, 16 insertions, 1 deletions
@@ -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, 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 */ }; /* |