Package org.xwiki.xml.html
Class HTMLUtils.XWikiXMLOutputter
- java.lang.Object
-
- org.jdom.output.XMLOutputter
-
- org.xwiki.xml.html.HTMLUtils.XWikiXMLOutputter
-
- All Implemented Interfaces:
Cloneable
- Enclosing class:
- HTMLUtils
public static class HTMLUtils.XWikiXMLOutputter extends org.jdom.output.XMLOutputterJDOM's XMLOutputter class converts reserved XML character (&) into its entity format&. However since we're using HTML Cleaner (http://htmlcleaner.sourceforge.net/) and since it's buggy for unicode character escapes we have turned off character escaping for it and thus we need to perform selective escaping here.Moreover, since we support HTML5, we need to expand empty elements on some elements and not on the others. For example:
<span></span>is valid meanwhile:
is not. See<br> </br>OMIT_ELEMENT_EXPANDING_SETfor the list of elements to not expand.
-
-
Constructor Summary
Constructors Constructor Description XWikiXMLOutputter(org.jdom.output.Format format, boolean omitDocType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringescapeAttributeEntities(String text)StringescapeElementEntities(String text)protected voidprintComment(Writer out, org.jdom.Comment comment)protected voidprintDocType(Writer out, org.jdom.DocType docType)protected voidprintElement(Writer out, org.jdom.Element element, int level, org.jdom.output.XMLOutputter.NamespaceStack namespaces)-
Methods inherited from class org.jdom.output.XMLOutputter
clone, getFormat, output, output, output, output, output, output, output, output, output, output, output, output, output, output, output, output, output, output, outputElementContent, outputElementContent, outputString, outputString, outputString, outputString, outputString, outputString, outputString, outputString, outputString, printAttributes, printCDATA, printDeclaration, printEntityRef, printProcessingInstruction, printText, setFormat, toString
-
-
-
-
Constructor Detail
-
XWikiXMLOutputter
public XWikiXMLOutputter(org.jdom.output.Format format, boolean omitDocType)- Parameters:
format- the JDOM class used to control output formats, seeFormatomitDocType- if true then omit the document type when printing the W3C Document- See Also:
XMLOutputter(Format)
-
-
Method Detail
-
escapeElementEntities
public String escapeElementEntities(String text)
- Overrides:
escapeElementEntitiesin classorg.jdom.output.XMLOutputter
-
escapeAttributeEntities
public String escapeAttributeEntities(String text)
- Overrides:
escapeAttributeEntitiesin classorg.jdom.output.XMLOutputter
-
printDocType
protected void printDocType(Writer out, org.jdom.DocType docType) throws IOException
- Overrides:
printDocTypein classorg.jdom.output.XMLOutputter- Throws:
IOException
-
printElement
protected void printElement(Writer out, org.jdom.Element element, int level, org.jdom.output.XMLOutputter.NamespaceStack namespaces) throws IOException
- Overrides:
printElementin classorg.jdom.output.XMLOutputter- Throws:
IOException
-
printComment
protected void printComment(Writer out, org.jdom.Comment comment) throws IOException
- Overrides:
printCommentin classorg.jdom.output.XMLOutputter- Throws:
IOException
-
-