Class TreeWalker


  • public class TreeWalker
    extends java.lang.Object
    This class does a pre-order walk of the DOM tree, calling a ContentHandler interface as it goes.
    • Constructor Summary

      Constructors 
      Constructor Description
      TreeWalker​(org.xml.sax.ContentHandler contentHandler)
      Constructor.
      TreeWalker​(org.xml.sax.ContentHandler contentHandler, DOMHelper dh)
      Constructor.
      TreeWalker​(org.xml.sax.ContentHandler contentHandler, DOMHelper dh, java.lang.String systemId)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.xml.sax.ContentHandler getContentHandler()
      Get the ContentHandler used for the tree walk.
      void setContentHandler​(org.xml.sax.ContentHandler ch)
      Get the ContentHandler used for the tree walk.
      void traverse​(org.w3c.dom.Node pos)
      Perform a pre-order traversal non-recursive style.
      void traverse​(org.w3c.dom.Node pos, org.w3c.dom.Node top)
      Perform a pre-order traversal non-recursive style.
      void traverseFragment​(org.w3c.dom.Node pos)
      Perform a pre-order traversal non-recursive style.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TreeWalker

        public TreeWalker​(org.xml.sax.ContentHandler contentHandler,
                          DOMHelper dh,
                          java.lang.String systemId)
        Constructor.
        Parameters:
        contentHandler - The implemention of the
        systemId - System identifier for the document. contentHandler operation (toXMLString, digest, ...)
      • TreeWalker

        public TreeWalker​(org.xml.sax.ContentHandler contentHandler,
                          DOMHelper dh)
        Constructor.
        Parameters:
        contentHandler - The implemention of the contentHandler operation (toXMLString, digest, ...)
      • TreeWalker

        public TreeWalker​(org.xml.sax.ContentHandler contentHandler)
        Constructor.
        Parameters:
        contentHandler - The implemention of the contentHandler operation (toXMLString, digest, ...)
    • Method Detail

      • getContentHandler

        public org.xml.sax.ContentHandler getContentHandler()
        Get the ContentHandler used for the tree walk.
        Returns:
        the ContentHandler used for the tree walk
      • setContentHandler

        public void setContentHandler​(org.xml.sax.ContentHandler ch)
        Get the ContentHandler used for the tree walk.
      • traverse

        public void traverse​(org.w3c.dom.Node pos)
                      throws org.xml.sax.SAXException
        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.
        Parameters:
        pos - Node in the tree where to start traversal
        Throws:
        TransformerException
        org.xml.sax.SAXException
      • traverseFragment

        public void traverseFragment​(org.w3c.dom.Node pos)
                              throws org.xml.sax.SAXException
        Perform a pre-order traversal non-recursive style. In contrast to the traverse() method this method will not issue startDocument() and endDocument() events to the SAX listener.
        Parameters:
        pos - Node in the tree where to start traversal
        Throws:
        TransformerException
        org.xml.sax.SAXException
      • traverse

        public void traverse​(org.w3c.dom.Node pos,
                             org.w3c.dom.Node top)
                      throws org.xml.sax.SAXException
        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.
        Parameters:
        pos - Node in the tree where to start traversal
        top - Node in the tree where to end traversal
        Throws:
        TransformerException
        org.xml.sax.SAXException