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.XMLOutputter
JDOM'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_SET
for 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 String
escapeAttributeEntities(String text)
String
escapeElementEntities(String text)
protected void
printComment(Writer out, org.jdom.Comment comment)
protected void
printDocType(Writer out, org.jdom.DocType docType)
protected void
printElement(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, seeFormat
omitDocType
- 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:
escapeElementEntities
in classorg.jdom.output.XMLOutputter
-
escapeAttributeEntities
public String escapeAttributeEntities(String text)
- Overrides:
escapeAttributeEntities
in classorg.jdom.output.XMLOutputter
-
printDocType
protected void printDocType(Writer out, org.jdom.DocType docType) throws IOException
- Overrides:
printDocType
in 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:
printElement
in classorg.jdom.output.XMLOutputter
- Throws:
IOException
-
printComment
protected void printComment(Writer out, org.jdom.Comment comment) throws IOException
- Overrides:
printComment
in classorg.jdom.output.XMLOutputter
- Throws:
IOException
-
-