Fixed restoring the context doc for XPath in xsltForEach(). Eliminated the
authorKasimier T. Buchcik <kbuchcik@src.gnome.org>
Thu, 10 Aug 2006 13:56:20 +0000 (13:56 +0000)
committerKasimier T. Buchcik <kbuchcik@src.gnome.org>
Thu, 10 Aug 2006 13:56:20 +0000 (13:56 +0000)
* libxslt/transform.c libxslt/variables.c
  libxslt/xsltInternals.h: Fixed restoring the context doc
  for XPath in xsltForEach(). Eliminated the use of @tmpDoc
  of the transformation context.

ChangeLog
libxslt/transform.c
libxslt/variables.c
libxslt/xsltInternals.h

index d1f3b88..e6a8e77 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Aug 10 15:54:02 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net
+
+       * libxslt/transform.c libxslt/variables.c
+         libxslt/xsltInternals.h: Fixed restoring the context doc
+         for XPath in xsltForEach(). Eliminated the use of @tmpDoc
+         of the transformation context.
+
 Thu Aug 10 13:40:35 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
 
        * libxslt/preproc.c: Added missing QName-validation of some
index 12233af..cde84e1 100644 (file)
@@ -4636,7 +4636,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
     xsltStackElemPtr withParams = NULL;
     int oldXPProximityPosition, oldXPContextSize;
     const xmlChar *oldMode, *oldModeURI;
-    xmlDocPtr oldDoc;
+    xmlDocPtr oldXPDoc;
     xsltDocumentPtr oldDocInfo;
     xmlXPathContextPtr xpctxt;
 
@@ -4662,7 +4662,6 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
     oldMode = ctxt->mode;
     oldModeURI = ctxt->modeURI;    
     oldDocInfo = ctxt->document;
-    oldDoc = ctxt->tmpDoc;
     oldList = ctxt->nodeList;    
 
     /*
@@ -4672,6 +4671,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
      */    
     oldXPContextSize = xpctxt->contextSize;
     oldXPProximityPosition = xpctxt->proximityPosition;
+    oldXPDoc = xpctxt->doc;
 
     /*
     * Set up contexts.
@@ -4989,11 +4989,10 @@ error:
     /*
     * Restore context states.
     */
-    xpctxt->doc = oldDoc;
+    xpctxt->doc = oldXPDoc;
     xpctxt->contextSize = oldXPContextSize;
     xpctxt->proximityPosition = oldXPProximityPosition;
-    
-    ctxt->tmpDoc = oldDoc;
+
     ctxt->document = oldDocInfo;
     ctxt->nodeList = oldList;
     ctxt->node = oldContextNode;
@@ -5401,7 +5400,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
     int oldXPProximityPosition, oldXPContextSize;
     xmlNodePtr oldContextNode;
     xsltTemplatePtr oldCurTemplRule;    
-    xmlDocPtr oldSourceDoc;
+    xmlDocPtr oldXPDoc;
     xsltDocumentPtr oldDocInfo;
     xmlXPathContextPtr xpctxt;
 
@@ -5435,8 +5434,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
     * Save context states.
     */
     oldDocInfo = ctxt->document;
-    oldList = ctxt->nodeList;
-    oldSourceDoc = ctxt->tmpDoc;
+    oldList = ctxt->nodeList;    
     oldContextNode = ctxt->node;
     /*
     * The "current template rule" is cleared for the instantiation of
@@ -5445,6 +5443,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
     oldCurTemplRule = ctxt->currentTemplateRule;
     ctxt->currentTemplateRule = NULL;
 
+    oldXPDoc = xpctxt->doc;
     oldXPProximityPosition = xpctxt->proximityPosition;
     oldXPContextSize = xpctxt->contextSize;
     /*
@@ -5574,13 +5573,12 @@ error:
     /*
     * Restore old states.
     */
-    ctxt->tmpDoc = oldSourceDoc;
     ctxt->document = oldDocInfo;
     ctxt->nodeList = oldList;
     ctxt->node = oldContextNode;
     ctxt->currentTemplateRule = oldCurTemplRule;
 
-    xpctxt->doc = oldSourceDoc;
+    xpctxt->doc = oldXPDoc;
     xpctxt->contextSize = oldXPContextSize;
     xpctxt->proximityPosition = oldXPProximityPosition;
 }
@@ -5961,7 +5959,6 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
     /*
     * Evaluate global params and user-provided params.
     */
-    ctxt->tmpDoc = doc;
     ctxt->node = (xmlNodePtr) doc;
     if (ctxt->globalVars == NULL)
        ctxt->globalVars = xmlHashCreate(20);
@@ -5974,7 +5971,6 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
     xsltCountKeys(ctxt);
 #endif
 
-    ctxt->tmpDoc = doc;
     ctxt->node = (xmlNodePtr) doc;
     ctxt->output = res;
     ctxt->insert = (xmlNodePtr) res;    
index 9c2075b..064d91d 100644 (file)
@@ -1490,16 +1490,7 @@ xsltProcessUserParamInternal(xsltTransformContextPtr ctxt,
            int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
            xmlNsPtr *oldXPNamespaces;
            xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;
-           /*
-           * SPEC XSLT 1.0:
-           * "At top-level, the expression or template specifying the
-           *  variable value is evaluated with the same context as that used
-           *  to process the root node of the source document: the current
-           *  node is the root node of the source document and the current
-           *  node list is a list containing just the root node of the source
-           *  document."
-           */
-           xpctxt->doc = ctxt->tmpDoc;
+          
            /*
            * Save context states.
            */
@@ -1509,9 +1500,18 @@ xsltProcessUserParamInternal(xsltTransformContextPtr ctxt,
            oldXPContextSize = xpctxt->contextSize;
            oldXPNamespaces = xpctxt->namespaces;
            oldXPNsNr = xpctxt->nsNr;
-           
-           xpctxt->node = ctxt->initialContextNode;
-           xpctxt->doc = ctxt->initialContextDoc;
+
+           /*
+           * SPEC XSLT 1.0:
+           * "At top-level, the expression or template specifying the
+           *  variable value is evaluated with the same context as that used
+           *  to process the root node of the source document: the current
+           *  node is the root node of the source document and the current
+           *  node list is a list containing just the root node of the source
+           *  document."
+           */
+           xpctxt->doc = ctxt->initialContextDoc;          
+           xpctxt->node = ctxt->initialContextNode;        
            xpctxt->contextSize = 1;
            xpctxt->proximityPosition = 1;
            /* 
index 8b995c8..38c504e 100644 (file)
@@ -1705,11 +1705,7 @@ struct _xsltTransformContext {
      * dictionnary: shared between stylesheet, context and documents.
      */
     xmlDictPtr dict;
-    /*
-     * The current source doc; one of: the initial source doc, a RTF
-     * or a source doc aquired via the document() function.
-     */
-    xmlDocPtr          tmpDoc;
+    xmlDocPtr          tmpDoc; /* Obsolete; not used in the library. */
     /*
      * all document text strings are internalized
      */