if (stylesheet.debug) { System.err.println("Applying " + t); }
  void doApply(Stylesheet stylesheet, QName mode,               Node context, int pos, int len,               Node parent, Node nextSibling)    throws TransformerException  {    Object ret = select.evaluate(context, pos, len);    if (ret != null && ret instanceof Collection)      {        if (withParams != null)          {            // push the parameter context            stylesheet.bindings.push(false);            // set the parameters            for (Iterator i = withParams.iterator(); i.hasNext(); )              {                WithParam p = (WithParam) i.next();                Object value = p.getValue(stylesheet, mode, context, pos, len);                stylesheet.bindings.set(p.name, value, false);              }          }        Collection ns = (Collection) ret;        List nodes = new ArrayList(ns);        if (sortKeys != null)          {            for (Iterator i = sortKeys.iterator(); i.hasNext(); )              {                SortKey sortKey = (SortKey) i.next();                sortKey.init(stylesheet, mode, context, pos, len, parent,                             nextSibling);              }            Collections.sort(nodes, new XSLComparator(sortKeys));          }        else          {            Collections.sort(nodes, documentOrderComparator);          }        int l = nodes.size();        QName effectiveMode = isDefault ? mode : this.mode;        for (int i = 0; i < l; i++)          {            Node node = (Node) nodes.get(i);            TemplateNode t = stylesheet.getTemplate(effectiveMode, node,                                                    false);            if (t != null)              {                if (stylesheet.debug)                  {                    System.err.println("Applying " + t);                  }                stylesheet.current = node;                t.apply(stylesheet, effectiveMode, node, i + 1, l,                        parent, nextSibling);              }          }        if (withParams != null)          {            // pop the variable context            stylesheet.bindings.pop(false);          }      }    // apply-templates doesn't have processable children    if (next != null)      {        next.apply(stylesheet, mode,                   context, pos, len,                   parent, nextSibling);      }  }