--- /home/cpdev/src/classpath/gnu/xml/transform/ParameterNode.java	2005-07-10 05:32:35.000000000 +0000
+++ gnu/xml/transform/ParameterNode.java	2005-06-30 05:34:21.000000000 +0000
@@ -53,51 +53,47 @@
  */
 final class ParameterNode
   extends TemplateNode
-  implements Comparable
 {
 
-  final QName name;
+  final String name;
   final Expr select;
-  final int type;
+  final boolean global;
 
-  ParameterNode(QName name, Expr select, int type)
+  ParameterNode(TemplateNode children, TemplateNode next,
+                String name, Expr select, boolean global)
   {
+    super(children, next);
     this.name = name;
     this.select = select;
-    this.type = type;
+    this.global = global;
   }
 
   TemplateNode clone(Stylesheet stylesheet)
   {
-    TemplateNode ret = new ParameterNode(name,
-                                         select.clone(stylesheet),
-                                         type);
-    if (children != null)
-      {
-        ret.children = children.clone(stylesheet);
-      }
-    if (next != null)
-      {
-        ret.next = next.clone(stylesheet);
-      }
-    return ret;
+    return new ParameterNode((children == null) ? null :
+                             children.clone(stylesheet),
+                             (next == null) ? null :
+                             next.clone(stylesheet),
+                             name,
+                             select.clone(stylesheet),
+                             global);
   }
 
   void doApply(Stylesheet stylesheet, QName mode,
-               Node context, int pos, int len,
-               Node parent, Node nextSibling)
+             Node context, int pos, int len,
+             Node parent, Node nextSibling)
     throws TransformerException
   {
-    // push the variable context
-    stylesheet.bindings.push(type);
-    // set the variable
-    Object value = getValue(stylesheet, mode, context, pos, len);
-    if (value != null)
+    boolean apply = global || !stylesheet.bindings.containsKey(name, global);
+    if (apply)
       {
-        stylesheet.bindings.set(name, value, type);
-        if (stylesheet.debug)
+        // push the variable context
+        stylesheet.bindings.push(global);
+        // set the variable
+        Object value = getValue(stylesheet, mode, context, pos, len);
+        if (value != null)
           {
-            System.err.println(this + ": set to " + value);
+            stylesheet.bindings.set(name, value, global);
           }
       }
     // variable and param don't process children as such
@@ -108,8 +104,11 @@
                    context, pos, len,
                    parent, nextSibling);
       }
-    // pop the variable context
-    stylesheet.bindings.pop(type);
+    if (apply)
+      {
+        // pop the variable context
+        stylesheet.bindings.pop(global);
+      }
   }
   
   Object getValue(Stylesheet stylesheet, QName mode,
@@ -134,38 +133,6 @@
       }
   }
   
-  public boolean references(QName var)
-  {
-    if (select != null && select.references(var))
-      {
-        return true;
-      }
-    return super.references(var);
-  }
-
-  public int compareTo(Object other)
-  {
-    if (other instanceof ParameterNode)
-      {
-        ParameterNode pn = (ParameterNode) other;
-        boolean r1 = references(pn.name);
-        boolean r2 = pn.references(name);
-        if (r1 && r2)
-          {
-            throw new IllegalArgumentException("circular definitions");
-          }
-        if (r1)
-          {
-            return 1;
-          }
-        if (r2)
-          {
-            return -1;
-          }
-      }
-    return 0;
-  }
-  
   public String toString()
   {
     StringBuffer buf = new StringBuffer(getClass().getName());
@@ -177,18 +144,9 @@
         buf.append(",select=");
         buf.append(select);
       }
-    buf.append(",type=");
-    switch (type)
+    if (global)
       {
-      case Bindings.VARIABLE:
-        buf.append("variable");
-        break;
-      case Bindings.PARAM:
-        buf.append("param");
-        break;
-      case Bindings.WITH_PARAM:
-        buf.append("with-param");
-        break;
+        buf.append(",global");
       }
     buf.append(']');
     return buf.toString();
