/**
   * Given a context node and the argument to the XPath <code>id</code> function, checks whether the
   * context node is in the set of nodes that results from that reference to the <code>id</code>
   * function. This is used in the implementation of <code>id</code> patterns.
   *
   * @param node The context node
   * @param value The argument to the <code>id</code> function
   * @return <code>1</code> if the context node is in the set of nodes returned by the reference to
   *     the <code>id</code> function; <code>0</code>, otherwise
   */
  public int containsID(int node, Object value) {
    final String string = (String) value;
    int rootHandle = _dom.getAxisIterator(Axis.ROOT).setStartNode(node).next();

    // Get the mapping table for the document containing the context node
    Hashtable index = (Hashtable) _rootToIndexMap.get(new Integer(rootHandle));

    // Split argument to id function into XML whitespace separated tokens
    final StringTokenizer values = new StringTokenizer(string, " \n\t");

    while (values.hasMoreElements()) {
      final String token = (String) values.nextElement();
      IntegerArray nodes = null;

      if (index != null) {
        nodes = (IntegerArray) index.get(token);
      }

      // If input was from W3C DOM, use DOM's getElementById to do
      // the look-up.
      if (nodes == null && _enhancedDOM != null && _enhancedDOM.hasDOMSource()) {
        nodes = getDOMNodeById(token);
      }

      // Did we find the context node in the set of nodes?
      if (nodes != null && nodes.indexOf(node) >= 0) {
        return 1;
      }
    }

    // Didn't find the context node in the set of nodes returned by id
    return 0;
  }
  /**
   * Callers should not call next() after it returns END.
   *
   * <p><em>Use of an instance of this class as a {@link DTMAxisIterator} is <b>deprecated.</b></em>
   *
   * @deprecated
   */
  public int next() {
    if (_nodes == null) return DTMAxisIterator.END;

    return (_position < _nodes.cardinality())
        ? _dom.getNodeHandle(_nodes.at(_position++))
        : DTMAxisIterator.END;
  }
  /**
   * Given a context node and the second argument to the XSLT <code>key</code> function, checks
   * whether the context node is in the set of nodes that results from that reference to the <code>
   * key</code> function. This is used in the implementation of key patterns.
   *
   * <p>This particular {@link KeyIndex} object is the result evaluating the first argument to the
   * <code>key</code> function, so it's not taken into any further account.
   *
   * @param node The context node
   * @param value The second argument to the <code>key</code> function
   * @return <code>1</code> if and only if the context node is in the set of nodes returned by the
   *     reference to the <code>key</code> function; <code>0</code>, otherwise
   */
  public int containsKey(int node, Object value) {
    int rootHandle = _dom.getAxisIterator(Axis.ROOT).setStartNode(node).next();

    // Get the mapping table for the document containing the context node
    Hashtable index = (Hashtable) _rootToIndexMap.get(new Integer(rootHandle));

    // Check whether the context node is present in the set of nodes
    // returned by the key function
    if (index != null) {
      final IntegerArray nodes = (IntegerArray) index.get(value);
      return (nodes != null && nodes.indexOf(node) >= 0) ? 1 : 0;
    }

    // The particular key name identifies no nodes in this document
    return 0;
  }