You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@apache.org on 2002/06/06 22:25:17 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/templates ElemVariable.java XUnresolvedVariable.java

sboag       2002/06/06 13:25:17

  Modified:    java/src/org/apache/xalan/templates ElemVariable.java
                        XUnresolvedVariable.java
  Log:
  Fix bug 7118.  In XUnresolvedVariable, treat the RTF variable much more like
  a template that has to count it's variables at compose-time, and link and unlink
  when the lazy variable is resolved.
  
  Revision  Changes    Path
  1.20      +35 -2     xml-xalan/java/src/org/apache/xalan/templates/ElemVariable.java
  
  Index: ElemVariable.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/ElemVariable.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ElemVariable.java	17 May 2002 22:35:29 -0000	1.19
  +++ ElemVariable.java	6 Jun 2002 20:25:17 -0000	1.20
  @@ -96,12 +96,19 @@
     public ElemVariable(){}
   
     /**
  -   * This is the index into the stack frame.  If the index is above the 
  -   * global area, it will have to be offset at execution time.
  +   * This is the index into the stack frame.
      */
     protected int m_index;
     
     /**
  +   * The stack frame size for this variable if it is a global variable 
  +   * that declares an RTF, which is equal to the maximum number 
  +   * of variables that can be declared in the variable at one time.
  +   */
  +  int m_frameSize = -1;
  +
  +  
  +  /**
      * Sets the relative position of this variable within the stack frame (if local)
      * or the global area (if global).  Note that this should be called only for
      * global variables since the local position is computed in the compose() method.
  @@ -391,12 +398,38 @@
       // Only add the variable if this is not a global.  If it is a global, 
       // it was already added by stylesheet root.
       if(!(m_parentNode instanceof Stylesheet))
  +    {
         m_index = cstate.addVariableName(m_qname) - cstate.getGlobalsSize();
  +    }
  +    else
  +    {
  +    	// If this is a global, then we need to treat it as if it's a xsl:template, 
  +    	// and count the number of variables it contains.  So we set the count to 
  +    	// zero here.
  +		cstate.resetStackFrameSize();
  +    }
       
       // This has to be done after the addVariableName, so that the variable 
       // pushed won't be immediately popped again in endCompose.
       super.compose(sroot);
     }
  +  
  +  /**
  +   * This after the template's children have been composed.  We have to get 
  +   * the count of how many variables have been declared, so we can do a link 
  +   * and unlink.
  +   */
  +  public void endCompose(StylesheetRoot sroot) throws TransformerException
  +  {
  +    super.endCompose(sroot);
  +    if(m_parentNode instanceof Stylesheet)
  +    {
  +    	StylesheetRoot.ComposeState cstate = sroot.getComposeState();
  +    	m_frameSize = cstate.getFrameSize();
  +    	cstate.resetStackFrameSize();
  +    }
  +  }
  +
     
     
   //  /**
  
  
  
  1.7       +9 -3      xml-xalan/java/src/org/apache/xalan/templates/XUnresolvedVariable.java
  
  Index: XUnresolvedVariable.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/templates/XUnresolvedVariable.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XUnresolvedVariable.java	12 Jun 2001 19:15:14 -0000	1.6
  +++ XUnresolvedVariable.java	6 Jun 2002 20:25:17 -0000	1.7
  @@ -157,12 +157,15 @@
       
       // These three statements need to be combined into one operation.
       int currentFrame = vars.getStackFrame();
  -    vars.setStackFrame(m_varStackPos);
  +    //// vars.setStackFrame(m_varStackPos);
  +   
   
  +    ElemVariable velem = (ElemVariable)m_obj;
       try
       {
         m_doneEval = false;
  -      ElemVariable velem = (ElemVariable)m_obj;
  +      if(-1 != velem.m_frameSize)
  +      	vars.link(velem.m_frameSize);
         XObject var = velem.getValue(m_transformer, m_context);
         m_doneEval = true;
         return var;
  @@ -170,7 +173,10 @@
       finally
       {
         // These two statements need to be combined into one operation.
  -      vars.setStackFrame(currentFrame);
  +      // vars.setStackFrame(currentFrame);
  +      
  +      if(-1 != velem.m_frameSize)
  +	  	vars.unlink(currentFrame);
       }
     }
     
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org