Class Stax2DomBuilder


  • public class Stax2DomBuilder
    extends Object
    Builds a DOM Document using a XMLStreamReader.
    Version:
    $Revision: 1.00 $, $Date: 2004/12/11 00:00:00 $
    Author:
    Tatu Saloranta
    • Field Detail

      • mCfgIgnoreWs

        protected boolean mCfgIgnoreWs
        Whether ignorable white space should be ignored, ie not added in the resulting JDOM tree. If true, it will be ignored; if false, it will be added in the tree. Default value if false.
      • mNsAware

        protected boolean mNsAware
      • mLastPrefix

        protected String mLastPrefix
      • mLastLocalName

        protected String mLastLocalName
      • mLastQName

        protected String mLastQName
    • Constructor Detail

      • Stax2DomBuilder

        public Stax2DomBuilder()
        Default constructor.
    • Method Detail

      • setIgnoreWhitespace

        public void setIgnoreWhitespace​(boolean ignoreWS)
        Method used to change whether the build methods will add ignorable (element) white space in the DOM tree or not.

        Whether all-whitespace text segment is ignorable white space or not is based on DTD read in, as per XML specifications (white space is only significant in mixed content or pure text elements).

        Parameters:
        ignoreWS - true to ignore whitespace; false otherwise.
      • build

        public void build​(XMLStreamReader r,
                          Document doc)
                   throws XMLStreamException
        This method will populate given Document using the given StAX stream reader instance.
        Parameters:
        r - Stream reader from which input is read.
        doc - Document - DOM document object.
        Throws:
        XMLStreamException - If the reader threw such exception (to indicate a parsing or I/O problem)
      • buildTree

        protected void buildTree​(XMLStreamReader r,
                                 Document doc)
                          throws XMLStreamException
        This method takes a XMLStreamReader and builds up a JDOM tree. Recursion has been eliminated by using nodes' parent/child relationship; this improves performance somewhat (classic recursion-by-iteration-and-explicit stack transformation)
        Parameters:
        r - Stream reader to use for reading the document from which to build the tree
        doc - JDOM Document being built.
        Throws:
        XMLStreamException - for fun