/**
   * Detaches the iterator from the set which it iterated over, releasing any computational
   * resources and placing the iterator in the INVALID state. After<code>detach</code> has been
   * invoked, calls to <code>nextNode</code> or<code>previousNode</code> will raise the exception
   * INVALID_STATE_ERR.
   */
  public void detach() {
    if (m_allowDetach) {
      m_traverser = null;

      // Always call the superclass detach last!
      super.detach();
    }
  }
  /**
   * Initialize the context values for this expression after it is cloned.
   *
   * @param context The XPath runtime context for this transformation.
   */
  public void setRoot(int context, Object environment) {

    super.setRoot(context, environment);

    if (null != m_firstWalker) {
      m_firstWalker.setRoot(context);
      m_lastUsedWalker = m_firstWalker;
    }
  }
  /** Reset the iterator. */
  public void reset() {

    super.reset();

    if (null != m_firstWalker) {
      m_lastUsedWalker = m_firstWalker;

      m_firstWalker.setRoot(m_context);
    }
  }
  /**
   * Detaches the iterator from the set which it iterated over, releasing any computational
   * resources and placing the iterator in the INVALID state. After<code>detach</code> has been
   * invoked, calls to <code>nextNode</code> or<code>previousNode</code> will raise the exception
   * INVALID_STATE_ERR.
   */
  public void detach() {
    if (m_allowDetach) {
      AxesWalker walker = m_firstWalker;
      while (null != walker) {
        walker.detach();
        walker = walker.getNextWalker();
      }

      m_lastUsedWalker = null;

      // Always call the superclass detach last!
      super.detach();
    }
  }
  /**
   * This will return an iterator capable of handling the union of paths given.
   *
   * @param compiler The Compiler which is creating this expression.
   * @param opPos The position of this iterator in the opcode list from the compiler.
   * @return Object that is derived from LocPathIterator.
   * @throws javax.xml.transform.TransformerException
   */
  public static LocPathIterator createUnionIterator(Compiler compiler, int opPos)
      throws javax.xml.transform.TransformerException {
    // For the moment, I'm going to first create a full UnionPathIterator, and
    // then see if I can reduce it to a UnionChildIterator.  It would obviously
    // be more effecient to just test for the conditions for a UnionChildIterator,
    // and then create that directly.
    UnionPathIterator upi = new UnionPathIterator(compiler, opPos);
    int nPaths = upi.m_exprs.length;
    boolean isAllChildIterators = true;
    for (int i = 0; i < nPaths; i++) {
      LocPathIterator lpi = upi.m_exprs[i];

      if (lpi.getAxis() != Axis.CHILD) {
        isAllChildIterators = false;
        break;
      } else {
        // check for positional predicates or position function, which won't work.
        if (HasPositionalPredChecker.check(lpi)) {
          isAllChildIterators = false;
          break;
        }
      }
    }
    if (isAllChildIterators) {
      UnionChildIterator uci = new UnionChildIterator();

      for (int i = 0; i < nPaths; i++) {
        PredicatedNodeTest lpi = upi.m_exprs[i];
        // I could strip the lpi down to a pure PredicatedNodeTest, but
        // I don't think it's worth it.  Note that the test can be used
        // as a static object... so it doesn't have to be cloned.
        uci.addNodeTest(lpi);
      }
      return uci;

    } else return upi;
  }
  /**
   * Initialize the context values for this expression after it is cloned.
   *
   * @param context The XPath runtime context for this transformation.
   */
  public void setRoot(int context, Object environment) {
    super.setRoot(context, environment);

    try {
      if (null != m_exprs) {
        int n = m_exprs.length;
        DTMIterator newIters[] = new DTMIterator[n];

        for (int i = 0; i < n; i++) {
          DTMIterator iter = m_exprs[i].asIterator(m_execContext, context);
          newIters[i] = iter;
          iter.nextNode();
        }
        m_iterators = newIters;
      }
    } catch (Exception e) {
      throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(e);
    }
  }
 /**
  * Initialize the context values for this expression after it is cloned.
  *
  * @param context The XPath runtime context for this transformation.
  */
 public void setRoot(int context, Object environment) {
   super.setRoot(context, environment);
   m_traverser = m_cdtm.getAxisTraverser(m_superAxis);
 }