code: public void traverse(Node pos) throws org.xml.sax.SAXException
    {
  
      this.m_contentHandler.startDocument();
  
      Node top = pos;
  
      while (null != pos)
      {
        startNode(pos);
  
        Node nextNode = pos.getFirstChild();
  
        while (null == nextNode)
        {
          endNode(pos);
  
          if (top.equals(pos))
            break;
  
          nextNode = pos.getNextSibling();
  
          if (null == nextNode)
          {
            pos = pos.getParentNode();
  
            if ((null == pos) || (top.equals(pos)))
            {
              if (null != pos)
                endNode(pos);
  
              nextNode = null;
  
              break;
            }
          }
        }
  
        pos = nextNode;
      }
      this.m_contentHandler.endDocument();
    }
docs: Perform a pre-order traversal non-recursive style.
  
  Note that TreeWalker assumes that the subtree is intended to represent
  a complete (though not necessarily well-formed) document and, during a
  traversal, startDocument and endDocument will always be issued to the
  SAX listener.
  
  @param pos Node in the tree where to start traversal
  
  @throws TransformerException