Пример #1
0
  /**
   * Moves the <code>TreeWalker</code> to the next visible node in document order relative to the
   * current node, and returns the new node. If the current node has no next node, or if the search
   * for nextNode attempts to step upward from the TreeWalker's root node, returns <code>null</code>
   * , and retains the current node.
   *
   * @return The new node, or <code>null</code> if the current node has no next node in the
   *     TreeWalker's logical view.
   */
  public int nextNode() {
    int nextNode = DTM.NULL;
    AxesWalker walker = wi().getLastUsedWalker();

    while (true) {
      if (null == walker) break;

      nextNode = walker.getNextNode();

      if (DTM.NULL == nextNode) {

        walker = walker.m_prevWalker;
      } else {
        if (walker.acceptNode(nextNode) != DTMIterator.FILTER_ACCEPT) {
          continue;
        }

        if (null == walker.m_nextWalker) {
          wi().setLastUsedWalker(walker);

          // return walker.returnNextNode(nextNode);
          break;
        } else {
          AxesWalker prev = walker;

          walker = walker.m_nextWalker;

          walker.setRoot(nextNode);

          walker.m_prevWalker = prev;

          continue;
        }
      } // if(null != nextNode)
    } // while(null != walker)

    return nextNode;
  }
Пример #2
0
 /**
  * Set the root node of the TreeWalker. (Not part of the DOM2 TreeWalker interface).
  *
  * @param root The context node of this step.
  */
 public void setRoot(int root) {
   super.setRoot(root);
   m_iterator = getDTM(root).getAxisIterator(m_axis);
   m_iterator.setStartNode(root);
 }