code: public int nextNode()
    {      
    	if(m_foundLast)
    		return DTM.NULL;
  
      int next;
      
      org.apache.xpath.VariableStack vars;
      int savedStart;
      if (-1 != m_stackFrame)
      {
        vars = m_execContext.getVarStack();
  
        // These three statements need to be combined into one operation.
        savedStart = vars.getStackFrame();
  
        vars.setStackFrame(m_stackFrame);
      }
      else
      {
        // Yuck.  Just to shut up the compiler!
        vars = null;
        savedStart = 0;
      }
      
      try
      {
        if(DEBUG)
          System.out.println("m_pattern"+m_pattern.toString());
  
        do
        {
          next = getNextNode();
    
          if (DTM.NULL != next)
          {
            if(DTMIterator.FILTER_ACCEPT == acceptNode(next, m_execContext))
              break;
            else
              continue;
          }
          else
            break;
        }
        while (next != DTM.NULL);
        
        if (DTM.NULL != next)
        {
          if(DEBUG)
          {
            System.out.println("next: "+next);
            System.out.println("name: "+m_cdtm.getNodeName(next));
          }
          incrementCurrentPos();
    
          return next;
        }
        else
        {
          m_foundLast = true;
    
          return DTM.NULL;
        }
      }
      finally
      {
        if (-1 != m_stackFrame)
        {
          // These two statements need to be combined into one operation.
          vars.setStackFrame(savedStart);
        }
      }
  
    }
docs: Returns the next node in the set and advances the position of the
  iterator in the set. After a NodeIterator is created, the first call
  to nextNode() returns the first node in the set.
  @return  The next <code>Node</code> in the set being iterated over, or
  <code>null</code> if there are no more members in that set.