Class TraversalDomSerializer


  • public class TraversalDomSerializer
    extends java.lang.Object
    A traversal-based serializer for DOM; used to avoid recursion and stack overflow for large HTML documents.
    • Field Detail

      • escapeXml

        protected boolean escapeXml
        Whether XML entities should be escaped or not.
      • deserializeCdataEntities

        protected boolean deserializeCdataEntities
      • strictErrorChecking

        protected boolean strictErrorChecking
    • Constructor Detail

      • TraversalDomSerializer

        public TraversalDomSerializer​(CleanerProperties props,
                                      boolean escapeXml,
                                      boolean deserializeCdataEntities,
                                      boolean strictErrorChecking)
        Parameters:
        props - the HTML Cleaner properties set by the user to control the HTML cleaning.
        escapeXml - if true then escape XML entities
        deserializeCdataEntities - if true then deserialize entities in CData sections
        strictErrorChecking - if false then Document strict error checking is turned off
      • TraversalDomSerializer

        public TraversalDomSerializer​(CleanerProperties props,
                                      boolean escapeXml,
                                      boolean deserializeCdataEntities)
        Parameters:
        props - the HTML Cleaner properties set by the user to control the HTML cleaning.
        escapeXml - if true then escape XML entities
        deserializeCdataEntities - if true then deserialize entities in CData sections
      • TraversalDomSerializer

        public TraversalDomSerializer​(CleanerProperties props,
                                      boolean escapeXml)
        Parameters:
        props - the HTML Cleaner properties set by the user to control the HTML cleaning.
        escapeXml - if true then escape XML entities
      • TraversalDomSerializer

        public TraversalDomSerializer​(CleanerProperties props)
        Parameters:
        props - the HTML Cleaner properties set by the user to control the HTML cleaning.
    • Method Detail

      • createDOM

        public org.w3c.dom.Document createDOM​(TagNode rootNode)
                                       throws javax.xml.parsers.ParserConfigurationException
        Parameters:
        rootNode - the HTML Cleaner root node to serialize
        Returns:
        the W3C Document object
        Throws:
        javax.xml.parsers.ParserConfigurationException - if there's an error during serialization
      • toString

        public static java.lang.String toString​(org.w3c.dom.Document doc)
                                         throws javax.xml.transform.TransformerException,
                                                javax.xml.parsers.ParserConfigurationException
        Throws:
        javax.xml.transform.TransformerException
        javax.xml.parsers.ParserConfigurationException