Class XWikiDOMSerializer


  • public class XWikiDOMSerializer
    extends org.htmlcleaner.DomSerializer
    Generate a W3C Document from a SF's HTML Cleaner TagNode. Some code has been copy-pasted from SF's HTML Cleaner code (which is under a BDS license, see http://htmlcleaner.sourceforge.net/license.php). Our goal is to remove this class completely if we can get SF's HTML Cleaner to support the usage of a dedicated builder. Here's the reason why we want to be able to give a dedicated builder: Note that creating the DocumentBuilder is not super fast but it's specifically more about the DocumentBuilderFactory creation mainly because it's blocking all the threads which are doing stuff implying loading a class from the classloader making it an important lock contention. I modified its behavior (and other similar tasks) after noticing that there was often a bunch of threads waiting for this kind of lock. Note: Even though in a public package this code is not meant to be a public API. We've had to put in under the org.htmlcleaner package because we use the following package protected API: TagNode#getNamespaceURIOnPath(String).
    Since:
    1.8.2
    Version:
    $Id: d54eedb46a3e899afd978864d1849ccc2c25202c $
    • Field Summary

      • Fields inherited from class org.htmlcleaner.DomSerializer

        deserializeCdataEntities, escapeXml, props, strictErrorChecking
    • Constructor Summary

      Constructors 
      Constructor Description
      XWikiDOMSerializer​(org.htmlcleaner.CleanerProperties props)  
    • Constructor Detail

      • XWikiDOMSerializer

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

      • createDOM

        public Document createDOM​(DocumentBuilder documentBuilder,
                                  org.htmlcleaner.TagNode rootNode)
                           throws ParserConfigurationException
        Create the DOM given a rootNode and a document builder. This method is a replica of DomSerializer.createDOM(TagNode) excepts that it requires to give a DocumentBuilder.
        Parameters:
        documentBuilder - the DocumentBuilder instance to use, DocumentBuilder is not guaranteed to be thread safe so at most the safe instance should be used only in the same thread
        rootNode - the HTML Cleaner root node to serialize
        Returns:
        the W3C Document object
        Throws:
        ParserConfigurationException - if there's an error during serialization