diff options
author | William M. Brack <wbrack@src.gnome.org> | 2004-11-25 14:32:45 +0000 |
---|---|---|
committer | William M. Brack <wbrack@src.gnome.org> | 2004-11-25 14:32:45 +0000 |
commit | 4ca8cab70f712428f56ade81876ac2c07a3bbcb0 (patch) | |
tree | 19dc9d6f28cc25ae532cbe715574374e7c818e28 | |
parent | 38c93a398f80f5dde5100299f02c5b0fcb680bb6 (diff) | |
download | libxslt-4ca8cab70f712428f56ade81876ac2c07a3bbcb0.tar.gz libxslt-4ca8cab70f712428f56ade81876ac2c07a3bbcb0.tar.bz2 libxslt-4ca8cab70f712428f56ade81876ac2c07a3bbcb0.zip |
backed out the last change and re-did it the "right way" (bug 158372).
* libxslt/variables.c, libxslt/xsltInternals.h: backed out the
last change and re-did it the "right way" (bug 158372).
* tests/general/bug-158.*, tests/general/Makefile.am,
tests/docs/bug-158.*, tests/general/Makefile.am: added test
case for this bug
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | libxslt/variables.c | 19 | ||||
-rw-r--r-- | libxslt/xsltInternals.h | 6 | ||||
-rw-r--r-- | libxslt/xsltwin32config.h | 2 | ||||
-rw-r--r-- | tests/docs/Makefile.am | 1 | ||||
-rw-r--r-- | tests/docs/bug-158.doc | 3 | ||||
-rw-r--r-- | tests/docs/bug-158.xml | 2 | ||||
-rw-r--r-- | tests/general/Makefile.am | 1 | ||||
-rw-r--r-- | tests/general/bug-158.out | 4 | ||||
-rw-r--r-- | tests/general/bug-158.xsl | 19 |
10 files changed, 53 insertions, 12 deletions
@@ -1,3 +1,11 @@ +Thu Nov 25 22:24:03 HKT 2004 William Brack <wbrack@mmm.com.hk> + + * libxslt/variables.c, libxslt/xsltInternals.h: backed out the + last change and re-did it the "right way" (bug 158372). + * tests/general/bug-158.*, tests/general/Makefile.am, + tests/docs/bug-158.*, tests/general/Makefile.am: added test + case for this bug + Wed Nov 24 10:51:51 HKT 2004 William Brack <wbrack@mmm.com.hk> * libxslt/variables.c, libxslt/xsltInternals.h: enhanced the diff --git a/libxslt/variables.c b/libxslt/variables.c index bcbcc322..e2d7fd44 100644 --- a/libxslt/variables.c +++ b/libxslt/variables.c @@ -563,6 +563,7 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt) { xmlXPathObjectPtr result = NULL; xsltStylePreCompPtr precomp; int oldProximityPosition, oldContextSize; + xmlDocPtr oldDoc; xmlNodePtr oldInst; int oldNsNr; xmlNsPtr *oldNamespaces; @@ -570,8 +571,7 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt) { if ((ctxt == NULL) || (elem == NULL)) return(NULL); - /* For pre-computation, need to correlate with the current document */ - if ((elem->computed) && (elem->doc == ctxt->xpathCtxt->doc)) + if (elem->computed) return(elem->value); @@ -580,12 +580,6 @@ 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) @@ -608,11 +602,13 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt) { elem->name = name; return(NULL); } + oldDoc = ctxt->xpathCtxt->doc; oldProximityPosition = ctxt->xpathCtxt->proximityPosition; oldContextSize = ctxt->xpathCtxt->contextSize; oldInst = ctxt->inst; oldNsNr = ctxt->xpathCtxt->nsNr; oldNamespaces = ctxt->xpathCtxt->namespaces; + if (precomp != NULL) { ctxt->inst = precomp->inst; ctxt->xpathCtxt->namespaces = precomp->nsList; @@ -622,8 +618,11 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt) { ctxt->xpathCtxt->namespaces = NULL; ctxt->xpathCtxt->nsNr = 0; } - ctxt->xpathCtxt->node = (xmlNodePtr) ctxt->node; + ctxt->xpathCtxt->doc = ctxt->tmpDoc; + ctxt->xpathCtxt->node = (xmlNodePtr) ctxt->tmpDoc; result = xmlXPathCompiledEval(comp, ctxt->xpathCtxt); + + ctxt->xpathCtxt->doc = oldDoc; ctxt->xpathCtxt->contextSize = oldContextSize; ctxt->xpathCtxt->proximityPosition = oldProximityPosition; ctxt->inst = oldInst; @@ -694,7 +693,6 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt) { if (result != NULL) { elem->value = result; elem->computed = 1; - elem->doc = ctxt->xpathCtxt->doc; } elem->name = name; return(result); @@ -722,6 +720,7 @@ xsltEvalGlobalVariables(xsltTransformContextPtr ctxt) { "Registering global variables\n")); #endif + ctxt->tmpDoc = ctxt->document->doc; ctxt->node = (xmlNodePtr) ctxt->document->doc; ctxt->xpathCtxt->contextSize = 1; ctxt->xpathCtxt->proximityPosition = 1; diff --git a/libxslt/xsltInternals.h b/libxslt/xsltInternals.h index 7b6f99a8..1378c73b 100644 --- a/libxslt/xsltInternals.h +++ b/libxslt/xsltInternals.h @@ -311,7 +311,6 @@ 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 */ }; /* @@ -552,6 +551,11 @@ struct _xsltTransformContext { * dictionnary: shared between stylesheet, context and documents. */ xmlDictPtr dict; + /* + * temporary storage for doc ptr, currently only used for + * global var evaluation + */ + xmlDocPtr tmpDoc; }; /** diff --git a/libxslt/xsltwin32config.h b/libxslt/xsltwin32config.h index f9a0558c..b542c1b4 100644 --- a/libxslt/xsltwin32config.h +++ b/libxslt/xsltwin32config.h @@ -44,7 +44,7 @@ extern "C" { * * extra version information, used to show a CVS compilation */ -#define LIBXML_VERSION_EXTRA "-CVS966" +#define LIBXML_VERSION_EXTRA "-CVS967" /** * WITH_XSLT_DEBUG: diff --git a/tests/docs/Makefile.am b/tests/docs/Makefile.am index cc00c88a..b0a1b08f 100644 --- a/tests/docs/Makefile.am +++ b/tests/docs/Makefile.am @@ -157,6 +157,7 @@ EXTRA_DIST = \ bug-155.xml \ bug-156.xml \ bug-157.xml \ + bug-158.xml bug-158.doc \ character.xml \ array.xml \ items.xml diff --git a/tests/docs/bug-158.doc b/tests/docs/bug-158.doc new file mode 100644 index 00000000..80b3f018 --- /dev/null +++ b/tests/docs/bug-158.doc @@ -0,0 +1,3 @@ +<site xmlns="http://www.decisionsoft.com/website-layout"> + <page path="path" /> +</site> diff --git a/tests/docs/bug-158.xml b/tests/docs/bug-158.xml new file mode 100644 index 00000000..19837413 --- /dev/null +++ b/tests/docs/bug-158.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8" ?> + <page xmlns="http://www.decisionsoft.com/website" path="path" /> diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am index 98059cad..25747fbc 100644 --- a/tests/general/Makefile.am +++ b/tests/general/Makefile.am @@ -166,6 +166,7 @@ EXTRA_DIST = \ bug-156.err bug-156.out bug-156.xsl \ bug-156.imp1.imp bug-156.imp2.imp \ bug-157.err bug-157.out bug-157.xsl \ + bug-158.out bug-158.xsl \ character.out character.xsl \ character2.out character2.xsl \ itemschoose.out itemschoose.xsl \ diff --git a/tests/general/bug-158.out b/tests/general/bug-158.out new file mode 100644 index 00000000..663816ca --- /dev/null +++ b/tests/general/bug-158.out @@ -0,0 +1,4 @@ +<?xml version="1.0"?> + +myPath is path +root is diff --git a/tests/general/bug-158.xsl b/tests/general/bug-158.xsl new file mode 100644 index 00000000..0e77175d --- /dev/null +++ b/tests/general/bug-158.xsl @@ -0,0 +1,19 @@ +<?xml version="1.0" ?> + +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" + xmlns:dsl="http://www.decisionsoft.com/website" + xmlns:html="http://www.w3.org/1999/xhtml" + xmlns:layout="http://www.decisionsoft.com/website-layout" + xmlns="http://www.w3.org/1999/xhtml"> + +<xsl:variable name="myPath" select="/dsl:page/@path" /> +<xsl:variable name="layout" select="document('../docs/bug158.doc')"/> +<xsl:variable name="root"><xsl:value-of select="$layout//layout:page[@path=$myPath]" /> +</xsl:variable> + +<xsl:template match="/"> +myPath is <xsl:value-of select="$myPath" /> +root is <xsl:value-of select="$root" /> +</xsl:template> + +</xsl:stylesheet> |