sboag       01/01/12 07:54:56

  Modified:    java/src/org/apache/xpath/axes UnionPathIterator.java
               java/src/org/apache/xpath/compiler Compiler.java
  Log:
  The isTopLevel state was not being set in LocPathIterators when they
  were in a union.  This caused the variable stack evaluation to be
  incorrect, and thus you could get bogus unresolved variable
  errors when executing a location path in a union that had a variable
  reference.
  
  Bug fix in response to report by Guoliang Cao <[EMAIL PROTECTED]>
  titled "Can I use recursive template with parameters? files are attached."
  on 01/10/2001 06:29 PM.  Actual test case sent via private email
  01/12/2001 02:55 AM.
  
  Revision  Changes    Path
  1.15      +7 -1      
xml-xalan/java/src/org/apache/xpath/axes/UnionPathIterator.java
  
  Index: UnionPathIterator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/axes/UnionPathIterator.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- UnionPathIterator.java    2001/01/02 03:47:15     1.14
  +++ UnionPathIterator.java    2001/01/12 15:54:55     1.15
  @@ -477,6 +477,9 @@
   
           LocPathIterator iter =
             new LocPathIterator(compiler.getNamespaceContext());
  +          
  +        if(compiler.getLocationPathDepth() <= 0)
  +          iter.setIsTopLevel(true);
   
           iter.m_firstWalker = new 
org.apache.xpath.axes.FilterExprWalker(iter);
   
  @@ -504,7 +507,10 @@
     protected LocPathIterator createLocPathIterator(
             Compiler compiler, int opPos) throws 
javax.xml.transform.TransformerException
     {
  -    return WalkerFactory.newLocPathIterator(compiler, opPos);
  +    LocPathIterator lpi = WalkerFactory.newLocPathIterator(compiler, opPos);
  +    if(compiler.getLocationPathDepth() <= 0)
  +      lpi.setIsTopLevel(true);
  +    return lpi;
     }
   
     /** The last node that was fetched, usually by nextNode. */
  
  
  
  1.20      +29 -6     
xml-xalan/java/src/org/apache/xpath/compiler/Compiler.java
  
  Index: Compiler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/compiler/Compiler.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- Compiler.java     2001/01/11 18:37:36     1.19
  +++ Compiler.java     2001/01/12 15:54:56     1.20
  @@ -632,10 +632,27 @@
      */
     protected Expression union(int opPos) throws TransformerException
     {
  -    return new UnionPathIterator(this, opPos);
  +    locPathDepth++;
  +    try
  +    {
  +      return new UnionPathIterator(this, opPos);
  +    }
  +    finally
  +    {
  +      locPathDepth--;
  +    }
     }
     
     private int locPathDepth = -1;
  +  
  +  /**
  +   * Get the level of the location path or union being constructed.  
  +   * @return 0 if it is a top-level path.
  +   */
  +  public int getLocationPathDepth()
  +  {
  +    return locPathDepth;
  +  }
   
     /**
      * Compile a location path.  The LocPathIterator itself may create
  @@ -650,11 +667,17 @@
     public Expression locationPath(int opPos) throws TransformerException
     {
       locPathDepth++;
  -    LocPathIterator iter = WalkerFactory.newLocPathIterator(this, opPos);
  -    if(locPathDepth == 0)
  -      iter.setIsTopLevel(true);
  -    locPathDepth--;
  -    return iter;
  +    try
  +    {
  +      LocPathIterator iter = WalkerFactory.newLocPathIterator(this, opPos);
  +      if(locPathDepth == 0)
  +        iter.setIsTopLevel(true);
  +      return iter;
  +    }
  +    finally
  +    {
  +      locPathDepth--;
  +    }
     }
   
     /**
  
  
  

Reply via email to