You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mm...@locus.apache.org on 2000/12/19 23:37:09 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/templates ElemApplyTemplates.java ElemCallTemplate.java ElemForEach.java

mmidy       00/12/19 14:37:07

  Modified:    java/src/org/apache/xalan/templates ElemApplyTemplates.java
                        ElemCallTemplate.java ElemForEach.java
  Log:
  Fix for variables out of context. Basically, searchstart need to be adjusted when variables or params are added because of an xsl:call-template or xsl:apply-templates. Note that Scott needs to do some additional work in this area!!!
  
  Revision  Changes    Path
  1.9       +18 -4     xml-xalan/java/src/org/apache/xalan/templates/ElemApplyTemplates.java
  
  Index: ElemApplyTemplates.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemApplyTemplates.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ElemApplyTemplates.java	2000/12/05 22:29:23	1.8
  +++ ElemApplyTemplates.java	2000/12/19 22:37:04	1.9
  @@ -222,19 +222,29 @@
      * @param sourceNode non-null reference to the <a href="http://www.w3.org/TR/xslt#dt-current-node">current source node</a>.
      * @param mode reference, which may be null, to the <a href="http://www.w3.org/TR/xslt#modes">current mode</a>.
      *
  +   * @return The original value of where to start the current search for a variable.
  +   * This value will be used by popParams to restore the value of
  +   * VariableStack.m_searchStart.
  +   * 
      * @throws TransformerException
      */
  -  void pushParams(
  +  int pushParams(
             TransformerImpl transformer, XPathContext xctxt, Node sourceNode, QName mode)
               throws TransformerException
     {
   
       VariableStack vars = xctxt.getVarStack();
  -
  +    int savedSearchStart = vars.getSearchStart();      
  +    
       if (null != m_paramElems)
  +    {  
         transformer.pushParams(xctxt, this, sourceNode, mode);
  +      vars.setSearchStart(-1);
  +    }  
       else
         vars.pushContextMarker();
  +    
  +    return savedSearchStart;
     }
   
     /**
  @@ -242,9 +252,13 @@
      *
      *
      * @param xctxt The XPath runtime state for this transformation.
  +   * @param savedSearchStart Value to restore VariableStack.m_searchStart
  +   * to. This is used to set where to start the current search for a variable.
      */
  -  void popParams(XPathContext xctxt)
  +  void popParams(XPathContext xctxt, int savedSearchStart)
     {
  -    xctxt.getVarStack().popCurrentContext();
  +    VariableStack vars = xctxt.getVarStack();
  +    vars.popCurrentContext();
  +    vars.setSearchStart(savedSearchStart);
     }
   }
  
  
  
  1.11      +4 -0      xml-xalan/java/src/org/apache/xalan/templates/ElemCallTemplate.java
  
  Index: ElemCallTemplate.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemCallTemplate.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ElemCallTemplate.java	2000/12/05 22:29:24	1.10
  +++ ElemCallTemplate.java	2000/12/19 22:37:04	1.11
  @@ -174,6 +174,9 @@
           transformer.pushParams(xctxt, this, sourceNode, mode);
         else
           vars.pushContextMarker();
  +      
  +      int savedSearchStart = vars.getSearchStart();
  +      vars.setSearchStart(-1);
   
         SourceLocator savedLocator = xctxt.getSAXLocator();
   
  @@ -190,6 +193,7 @@
           transformer.popElemTemplateElement();
           xctxt.setSAXLocator(savedLocator);
           vars.popCurrentContext();
  +        vars.setSearchStart(savedSearchStart);
         }
       }
       else
  
  
  
  1.13      +17 -6     xml-xalan/java/src/org/apache/xalan/templates/ElemForEach.java
  
  Index: ElemForEach.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemForEach.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ElemForEach.java	2000/12/05 22:29:27	1.12
  +++ ElemForEach.java	2000/12/19 22:37:05	1.13
  @@ -312,9 +312,13 @@
      * @param sourceNode non-null reference to the <a href="http://www.w3.org/TR/xslt#dt-current-node">current source node</a>.
      * @param mode reference, which may be null, to the <a href="http://www.w3.org/TR/xslt#modes">current mode</a>.
      *
  +   * @return -1, this return will not be used by ElemForEach. 
  +   * It is just there because ElemApplyTemplates which derives
  +   * from this needs to that value to be saved.
  +   *     
      * @throws TransformerException
      */
  -  void pushParams(
  +  int pushParams(
             TransformerImpl transformer, XPathContext xctxt, Node sourceNode, QName mode)
               throws TransformerException
     {
  @@ -322,6 +326,7 @@
       VariableStack vars = xctxt.getVarStack();
   
       vars.pushElemFrame();
  +    return -1;
     }
   
     /**
  @@ -329,8 +334,11 @@
      *
      *
      * @param xctxt The XPath runtime state.
  +   * @param savedSearchStart This param will not be used by ElemForEach. 
  +   * It is just there because ElemApplyTemplates which derives
  +   * from this needs to restore that value. 
      */
  -  void popParams(XPathContext xctxt)
  +  void popParams(XPathContext xctxt, int savedSearchStart)
     {
   
       VariableStack vars = xctxt.getVarStack();
  @@ -381,7 +389,10 @@
         if (null != keys)
           sourceNodes = sortNodes(xctxt, keys, sourceNodes);
   
  -      pushParams(transformer, xctxt, sourceNode, mode);
  +      // The returned value is only relevant for ElemApplyTemplates.
  +      // This value needs to be passed to popParams which will
  +      // restore it in the variable stack.
  +      int savedSearchStart = pushParams(transformer, xctxt, sourceNode, mode);
   
         // Push the ContextNodeList on a stack, so that select="position()"
         // and the like will work.
  @@ -400,7 +411,7 @@
         boolean check = (guard.m_recursionLimit > -1);
         boolean quiet = transformer.getQuietConflictWarnings();
         boolean needToFindTemplate = (null == template);
  -
  +      
         try
         {
           Node child;
  @@ -512,9 +523,9 @@
           xctxt.setSAXLocator(savedLocator);
           xctxt.popContextNodeList();
           transformer.popElemTemplateElement();
  -        popParams(xctxt);
  +        popParams(xctxt, savedSearchStart);
           // if(null != sourceNodes)
  -        //  sourceNodes.detach();
  +        //  sourceNodes.detach();                
         }
       }
       catch(SAXException se)