public class XHTMLSerializer extends XHTMLSerializer implements LogEnabled, Serviceable
The following configuration can be used:
<omit-xml-declaration>yes|no</omit-xml-declaration> <tags-to-collapse>input,meta</tags-to-collapse> <namespace-allowed></namespace-allowed> <namespace-allowed>http://www.w3.org/XML/1998/namespace</namespace-allowed> <namespace-allowed>http://www.w3.org/1999/xhtml</namespace-allowed>Empty tags are not collapsed except the ones configured with
tags-to-collapse
.namespace-allowed
, by default
the only following namespaces are allowed:
script
tags will be exported in a single comment.
omit-xml-declaration
is set to yes
by default for
compatibility purpose (IE 6).
If omit-xml-declaration
is set to no
,
Content-Type
meta tag will be dropped if present.
javax.xml.transform.*-output-escaping processing
.Result
Modifier and Type | Field and Description |
---|---|
private static Set<String> |
__COLLAPSE_TAGS
List of the tags to collapse.
|
private static String |
__HEAD_TAG
Head tag.
|
private static String |
__META_CONTENT_ATTR
Meta content attribute name.
|
private static String |
__META_HTTP_EQUIV_ATTR
Meta HTTP equiv attribute name.
|
private static String |
__META_HTTP_EQUIV_CTYPE_VALUE
Meta HTTP equiv attribute value for content type.
|
private static String |
__META_TAG
Meta tag.
|
private static Set<String> |
__NAMESPACES_ALLOWED
List of the tags to collapse.
|
private static String |
__SCRIPT_TAG
Script tag.
|
private static String |
__STYLE_TAG
Style tag.
|
private StringBuilder |
_buffer
Buffer to store script tag content.
|
private boolean |
_disableOutputEscaping
Flag for disabling output escaping states encountered with
javax.xml.transform.*-output-escaping processing instructions. |
private int |
_insideFilteredTag
Inside filtered tag: greater than 0 if we are inside a filtered tag.
|
private int |
_insideInlineResourceTag
Inline resource context: greater than 0 if we are inside a style or a script tag.
|
private boolean |
_isMetaContentType
Meta http-equiv="Content-Type" context.
|
private Logger |
_logger |
private Set<String> |
_namespacesAllowed
Namespaces allowed.
|
private Set<String> |
_namespacesPrefixFiltered
Namespaces prefixe filtered.
|
private boolean |
_omitXmlDeclaration
Define whether to put XML declaration in the head of the document.
|
private int |
_tagsInsideInlineResourceTag |
private Set<String> |
_tagsToCollapse
Buffer to store tag to collapse.
|
protected XHTMLSerializerExtensionPoint |
_xhtmlSerializerExtensionPoint
The XHTMLSerializerExtensionPoint instance
|
doctype_default, encodeCharacters, XHTML1_DOCTYPE_FRAMESET, XHTML1_DOCTYPE_STRICT, XHTML1_DOCTYPE_TRANSITIONAL, XHTML1_NAMESPACE, XHTML5_DOCTYPE
doctype
ATTRIBUTE_LENGTH, ATTRIBUTE_LOCAL, ATTRIBUTE_NSURI, ATTRIBUTE_QNAME, ATTRIBUTE_VALUE, charset, indentPerLevel, namespaces
ROLE
Constructor and Description |
---|
XHTMLSerializer() |
Modifier and Type | Method and Description |
---|---|
private Attributes |
_filterAttributes(Attributes attributes) |
void |
characters(char[] ch,
int start,
int length) |
void |
charactersImpl(char[] data,
int start,
int length) |
void |
comment(char[] data,
int start,
int length) |
void |
configure(Configuration conf) |
void |
enableLogging(Logger logger) |
void |
endElement(String nsuri,
String local,
String qual) |
void |
endElementImpl(String uri,
String local,
String qual) |
void |
endPrefixMapping(String prefix) |
void |
ignorableWhitespace(char[] data,
int start,
int length) |
private boolean |
isJsScript(String local,
String[][] attributes) |
private boolean |
isMetaContentType(String local,
String[][] attributes) |
void |
processingInstruction(String target,
String data) |
void |
recycle() |
void |
service(ServiceManager manager) |
void |
startElement(String nsuri,
String local,
String qual,
Attributes attributes) |
void |
startElementImpl(String uri,
String local,
String qual,
String[][] lNamespaces,
String[][] attributes) |
void |
startPrefixMapping(String prefix,
String uri) |
body, encode, getMimeType, head, isCdataElement
closeElement, endCDATA, endDocument, endDTD, endEntity, skippedEntity, startCDATA, startDocument, startDTD, startEntity
encode, encode, flush, getColumnNumber, getLineNumber, getLocation, getPublicId, getSystemId, setDocumentLocator, setOutputStream, shouldSetContentLength, write, write, write, write, write, writeIndent, writeln, writeln
private static final Set<String> __NAMESPACES_ALLOWED
private static final Set<String> __COLLAPSE_TAGS
private static final String __HEAD_TAG
private static final String __META_TAG
private static final String __META_HTTP_EQUIV_ATTR
private static final String __META_HTTP_EQUIV_CTYPE_VALUE
private static final String __META_CONTENT_ATTR
private static final String __SCRIPT_TAG
private static final String __STYLE_TAG
protected XHTMLSerializerExtensionPoint _xhtmlSerializerExtensionPoint
private StringBuilder _buffer
private Set<String> _tagsToCollapse
private Set<String> _namespacesAllowed
private Set<String> _namespacesPrefixFiltered
private int _insideFilteredTag
private int _insideInlineResourceTag
private int _tagsInsideInlineResourceTag
private boolean _disableOutputEscaping
javax.xml.transform.*-output-escaping
processing instructions.private boolean _omitXmlDeclaration
private boolean _isMetaContentType
public XHTMLSerializer()
public void enableLogging(Logger logger)
enableLogging
in interface LogEnabled
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void configure(Configuration conf) throws ConfigurationException
configure
in interface Configurable
configure
in class XHTMLSerializer
ConfigurationException
public void startPrefixMapping(String prefix, String uri) throws SAXException
startPrefixMapping
in interface ContentHandler
startPrefixMapping
in class EncodingSerializer
SAXException
public void startElement(String nsuri, String local, String qual, Attributes attributes) throws SAXException
startElement
in interface ContentHandler
startElement
in class EncodingSerializer
SAXException
private Attributes _filterAttributes(Attributes attributes)
public void startElementImpl(String uri, String local, String qual, String[][] lNamespaces, String[][] attributes) throws SAXException
startElementImpl
in class XHTMLSerializer
SAXException
public void characters(char[] ch, int start, int length) throws SAXException
characters
in interface ContentHandler
characters
in class EncodingSerializer
SAXException
public void charactersImpl(char[] data, int start, int length) throws SAXException
charactersImpl
in class XMLSerializer
SAXException
public void ignorableWhitespace(char[] data, int start, int length) throws SAXException
ignorableWhitespace
in interface ContentHandler
ignorableWhitespace
in class XMLSerializer
SAXException
public void comment(char[] data, int start, int length) throws SAXException
comment
in interface LexicalHandler
comment
in class XMLSerializer
SAXException
public void processingInstruction(String target, String data) throws SAXException
processingInstruction
in interface ContentHandler
processingInstruction
in class XMLSerializer
SAXException
public void endElement(String nsuri, String local, String qual) throws SAXException
endElement
in interface ContentHandler
endElement
in class EncodingSerializer
SAXException
public void endElementImpl(String uri, String local, String qual) throws SAXException
endElementImpl
in class XHTMLSerializer
SAXException
public void endPrefixMapping(String prefix) throws SAXException
endPrefixMapping
in interface ContentHandler
endPrefixMapping
in class EncodingSerializer
SAXException
private boolean isMetaContentType(String local, String[][] attributes)
private boolean isJsScript(String local, String[][] attributes)
public void recycle()
recycle
in interface Recyclable
recycle
in class XMLSerializer