mkwan       2002/09/06 11:12:24

  Modified:    java/src/org/apache/xpath/functions FuncExtFunction.java
  Log:
  For Bugzilla 11743 and 12298. Fix argument handling in
  extension functions. Arguments now have non-null parents
  and they will be visited by the XPathVisitor.
  
  Revision  Changes    Path
  1.17      +69 -0     
xml-xalan/java/src/org/apache/xpath/functions/FuncExtFunction.java
  
  Index: FuncExtFunction.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xpath/functions/FuncExtFunction.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- FuncExtFunction.java      10 Jun 2002 20:47:44 -0000      1.16
  +++ FuncExtFunction.java      6 Sep 2002 18:12:24 -0000       1.17
  @@ -59,7 +59,10 @@
   import java.util.Vector;
   
   import org.apache.xpath.Expression;
  +import org.apache.xpath.ExpressionOwner;
  +import org.apache.xpath.ExpressionNode;
   import org.apache.xpath.XPathContext;
  +import org.apache.xpath.XPathVisitor;
   import org.apache.xpath.ExtensionsProvider;
   import org.apache.xpath.objects.*;
   import org.apache.xalan.transformer.TransformerImpl;
  @@ -233,6 +236,72 @@
      * @throws WrongNumberArgsException
      */
     public void checkNumberArgs(int argNum) throws WrongNumberArgsException{}
  +
  +
  +  class ArgExtOwner implements ExpressionOwner
  +  {
  +  
  +    Expression m_exp;
  +     
  +     ArgExtOwner(Expression exp)
  +     {
  +             m_exp = exp;
  +     }
  +     
  +    /**
  +     * @see ExpressionOwner#getExpression()
  +     */
  +    public Expression getExpression()
  +    {
  +      return m_exp;
  +    }
  +
  +
  +    /**
  +     * @see ExpressionOwner#setExpression(Expression)
  +     */
  +    public void setExpression(Expression exp)
  +    {
  +     exp.exprSetParent(FuncExtFunction.this);
  +     m_exp = exp;
  +    }
  +  }
  +  
  +  
  +  /**
  +   * Call the visitors for the function arguments.
  +   */
  +  public void callArgVisitors(XPathVisitor visitor)
  +  {
  +      for (int i = 0; i < m_argVec.size(); i++)
  +      {
  +         Expression exp = (Expression)m_argVec.get(i);
  +         exp.callVisitors(new ArgExtOwner(exp), visitor);
  +      }
  +    
  +  }
  +
  +  /**
  +   * Set the parent node.
  +   * For an extension function, we also need to set the parent
  +   * node for all argument expressions.
  +   * 
  +   * @param n The parent node
  +   */
  +  public void exprSetParent(ExpressionNode n) 
  +  {
  +     
  +    super.exprSetParent(n);
  +      
  +    int nArgs = m_argVec.size();
  +
  +    for (int i = 0; i < nArgs; i++)
  +    {
  +      Expression arg = (Expression) m_argVec.elementAt(i);
  +
  +      arg.exprSetParent(n);
  +    }                
  +  }
   
     /**
      * Constructs and throws a WrongNumberArgException with the appropriate
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to