Hi Asiri,

On Mar 16, 2009, at 6:58 PM, asiri (SVN) wrote:

> Author: asiri
> Date: 2009-03-16 18:58:57 +0100 (Mon, 16 Mar 2009)
> New Revision: 17677
>
> Modified:
>   platform/core/trunk/xwiki-xml/pom.xml
>   platform/core/trunk/xwiki-xml/src/main/java/org/xwiki/xml/internal/ 
> html/DefaultHTMLCleaner.java
> Log:
> XWIKI-3365: Get rid of jdom dependency in xwiki-xml module
>
> * Fixed.

[snip]

> +        }
>         // Workaround HTML XML declaration bug.
> -        fixCleanedNodeBug(cleanedNode);
> -
> -        // Ideally following code should be enough. But SF's HTML  
> Cleaner seems to omit the DocType declaration while
> -        // serializing.
> -        // See 
> https://sourceforge.net/tracker/index.php?func=detail&aid=2062318&group_id=183053&atid=903696
> -        //      cleanedNode.setDocType(new DoctypeToken("html",  
> "PUBLIC", "-//W3C//DTD XHTML 1.0 Strict//EN",
> -        //          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd 
> "));
> -        //      try {
> -        //          result = new DomSerializer(cleanerProperties,  
> false).createDOM(cleanedNode);
> -        //      } catch(ParserConfigurationException ex) { }
> -        // As a workaround, we have go through JDOM so that we can  
> set the DocType manually.
> -        org.jdom.Document jdomDoc = null;
> -        jdomDoc = new JDomSerializer(cleanerProperties,  
> false).createJDom(cleanedNode);
> -        jdomDoc.setDocType(new DocType("html", "-//W3C//DTD XHTML  
> 1.0 Strict//EN",
> -            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";));
> +        fixCleanedNodeBug(cleanedNode);
> +        // Serialize the cleanedNode TagNode into a w3c dom.
>         try {
> -            result = new DOMOutputter().output(jdomDoc);
> -        } catch (JDOMException ex) {
> -            throw new RuntimeException("Error while transforming  
> jdom document into w3c document", ex);
> +            Document tempDoc = new DomSerializer(cleanerProperties,  
> false).createDOM(cleanedNode);
> +            DOMImplementation domImpl =
> +                 
> DocumentBuilderFactory 
> .newInstance().newDocumentBuilder().getDOMImplementation();
> +            DocumentType docType =
> +                domImpl.createDocumentType(QUALIFIED_NAME_HTML, "-// 
> W3C//DTD XHTML 1.0 Strict//EN",
> +                    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd 
> ");
> +            result = domImpl.createDocument(null,  
> QUALIFIED_NAME_HTML, docType);
> +             
> result.replaceChild(result.adoptNode(tempDoc.getDocumentElement()),  
> result.getDocumentElement());
> +        } catch (ParserConfigurationException ex) {
> +            throw new RuntimeException("Error while serializing  
> TagNode into w3c dom.", ex);

cool but why have you removed the comment saying that there's a SF  
html cleaner bug? Can you put it back and instead add that this is  
workaround?

Thanks
-Vincent
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to