public class HTML5Serializer extends Object implements ContentHandler
Writer as a UTF-8-encoded HTML 5 document. The SAX events
must represent a valid XHTML 1.0 document, except the namespace prefixes
don't matter and there may be startElement and endElement
calls for elements from other namespaces. The startElement and
endElement calls for non-XHTML elements are ignored. No
validity checking is performed. Hence, the emitter of the SAX events is
responsible for making sure the events represent a document that meets the
above requirements. The Writer is not closed when the end of
the document is seen.| Constructor and Description |
|---|
HTML5Serializer(Writer writer)
Creates a new instance of HtmlSerializer in the HTML 4.01 doctype mode
with the UTF-8 encoding and no charset meta.
|
| Modifier and Type | Method and Description |
|---|---|
void |
characters(char[] ch,
int start,
int length)
Writes out characters.
|
void |
endDocument()
Must be called last.
|
void |
endElement(String namespaceURI,
String localName,
String qName)
Writes an end tag if the element is an XHTML element and is not an empty
element in HTML 4.01 Strict.
|
void |
endPrefixMapping(String str)
This method does nothing.
|
void |
ignorableWhitespace(char[] values,
int param,
int param2)
This method does nothing.
|
void |
processingInstruction(String str,
String str1)
This method does nothing.
|
void |
setDocumentLocator(Locator locator)
This method does nothing.
|
void |
skippedEntity(String str)
This method does nothing.
|
void |
startDocument()
Must be called first.
|
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
Writes a start tag if the element is an XHTML element.
|
void |
startPrefixMapping(String str,
String str1)
This method does nothing.
|
public HTML5Serializer(Writer writer)
writer - the writer to which the output is writtenpublic void characters(char[] ch,
int start,
int length)
throws SAXException
characters in interface ContentHandlerch - the source arraystart - the index of the first character to be writtenlength - the number of characters to writeSAXException - if there are IO problemspublic void endDocument()
throws SAXException
endDocument in interface ContentHandlerSAXException - if there are IO problemspublic void endElement(String namespaceURI, String localName, String qName) throws SAXException
endElement in interface ContentHandlernamespaceURI - the XML namespacelocalName - the element name in the namespaceqName - ignoredSAXException - if there are IO problemspublic void startDocument()
throws SAXException
startDocument in interface ContentHandlerSAXExceptionpublic void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException
startElement in interface ContentHandlernamespaceURI - the XML namespacelocalName - the element name in the namespaceqName - ignoredatts - the attribute listSAXException - if there are IO problemspublic void endPrefixMapping(String str) throws SAXException
endPrefixMapping in interface ContentHandlerSAXExceptionpublic void ignorableWhitespace(char[] values,
int param,
int param2)
throws SAXException
ignorableWhitespace in interface ContentHandlerSAXExceptionpublic void processingInstruction(String str, String str1) throws SAXException
processingInstruction in interface ContentHandlerSAXExceptionpublic void setDocumentLocator(Locator locator)
setDocumentLocator in interface ContentHandlerpublic void skippedEntity(String str) throws SAXException
skippedEntity in interface ContentHandlerSAXExceptionpublic void startPrefixMapping(String str, String str1) throws SAXException
startPrefixMapping in interface ContentHandlerSAXExceptionCopyright © 2018 The International Consortium of Investigative Journalists. All rights reserved.