morten      01/08/07 03:38:44

  Modified:    java/src/org/apache/xalan/xsltc/compiler ForEach.java
                        xpath.cup
               java/src/org/apache/xalan/xsltc/runtime
                        AbstractTranslet.java
  Log:
  Fix for passing node-sets as parameters into a template with a for-each loop.
  The ForEach class resets its node iterator by default. This behaviour is not
  desierd for iterators that are passed in through a parameter, so I added an
  it-test that checks if the iterator is of type 'Reference'.
  PR:           bugzilla 2468
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.8       +9 -5      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ForEach.java
  
  Index: ForEach.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ForEach.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ForEach.java      2001/06/29 14:58:55     1.7
  +++ ForEach.java      2001/08/07 10:38:44     1.8
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: ForEach.java,v 1.7 2001/06/29 14:58:55 morten Exp $
  + * @(#)$Id: ForEach.java,v 1.8 2001/08/07 10:38:44 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -77,7 +77,9 @@
   import org.apache.xalan.xsltc.compiler.util.*;
   
   final class ForEach extends Instruction {
  +
       private Expression _select;
  +    private Type       _tselect;
   
       public void display(int indent) {
        indent(indent);
  @@ -100,14 +102,14 @@
       }
        
       public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  -     Type tselect = _select.typeCheck(stable);
  +     _tselect = _select.typeCheck(stable);
   
  -     if (tselect instanceof ReferenceType || tselect instanceof NodeType) {
  +     if (_tselect instanceof ReferenceType || _tselect instanceof NodeType) {
            _select = new CastExpr(_select, Type.NodeSet);
            typeCheckContents(stable);
            return Type.Void;
        }
  -     else if (tselect instanceof NodeSetType) {
  +     else if (_tselect instanceof NodeSetType) {
            typeCheckContents(stable);
            return Type.Void;
        } 
  @@ -142,8 +144,10 @@
            if (_select instanceof Step) {
                ((Step)_select).orderIterator(classGen, methodGen);
            }
  +     }
  +     if (!(_tselect instanceof ReferenceType)) {
  +         _select.startResetIterator(classGen, methodGen);
        }
  -     _select.startResetIterator(classGen, methodGen);
   
        // Overwrite current iterator
        il.append(methodGen.storeIterator());
  
  
  
  1.5       +1 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup
  
  Index: xpath.cup
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- xpath.cup 2001/06/19 10:44:13     1.4
  +++ xpath.cup 2001/08/07 10:38:44     1.5
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: xpath.cup,v 1.4 2001/06/19 10:44:13 morten Exp $
  + * @(#)$Id: xpath.cup,v 1.5 2001/08/07 10:38:44 morten Exp $
    *
    * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
    * 
  @@ -626,7 +626,6 @@
               }
   
               if (node == null) {
  -             System.err.println("looking for var "+varName);
                   RESULT = parser.DummyVarRef;
                   parser.addError(new ErrorMsg(ErrorMsg.VARUNDEF_ERR,
                    parser.getLineNumber(), varName));
  
  
  
  1.16      +3 -4      
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
  
  Index: AbstractTranslet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- AbstractTranslet.java     2001/07/30 13:35:41     1.15
  +++ AbstractTranslet.java     2001/08/07 10:38:44     1.16
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: AbstractTranslet.java,v 1.15 2001/07/30 13:35:41 morten Exp $
  + * @(#)$Id: AbstractTranslet.java,v 1.16 2001/08/07 10:38:44 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -164,6 +164,7 @@
        */
       public final Object addParameter(String name, Object value,
                                     boolean isDefault) {
  +
        // Local parameters need to be re-evaluated for each iteration
        for (int i = pframe - 1; i >= pbase; i--) {
            final Parameter param = (Parameter) paramsStack.elementAt(i);
  @@ -199,9 +200,7 @@
       public final Object getParameter(String name) {
        for (int i = pframe - 1; i >= pbase; i--) {
            final Parameter param = (Parameter)paramsStack.elementAt(i);
  -         if (param._name.equals(name)) {
  -             return param._value;
  -         }
  +         if (param._name.equals(name)) return param._value;
        }
        return null;
       }
  
  
  

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

Reply via email to