Package org.ametys.core.cocoon
Class XHTMLSerializer
-
- All Implemented Interfaces:
Poolable,Recyclable,Component,Configurable,LogEnabled,Serviceable,Serializer,SitemapOutputComponent,XMLConsumer,XMLConsumer,ContentHandler,LexicalHandler,Locator
public class XHTMLSerializer extends XHTMLSerializer implements LogEnabled, Serviceable
Inherits from cocoon's serializers block XHTMLSerializer.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 withtags-to-collapse.
If there is no such configuration, default tags to collaspe are:- input
- img
- meta
- link
- hr
- br
namespace-allowed, by default the only following namespaces are allowed:- "" (empty namespace)
- "http://www.w3.org/XML/1998/namespace"
- "http://www.w3.org/1999/xhtml"
- "http://www.w3.org/2000/svg"
- "http://www.w3.org/1998/Math/MathML"
scripttags will be exported in a single comment.omit-xml-declarationis set toyesby default for compatibility purpose (IE 6). Ifomit-xml-declarationis set tono,Content-Typemeta tag will be dropped if present.- Since:
- 1.1.5 this serializer is JAXP compliant with the processing instruction
javax.xml.transform.*-output-escaping processing. - See Also:
Result
-
-
Field Summary
Fields Modifier and Type Field Description private static Set<String>__COLLAPSE_TAGSList of the tags to collapse.private static String__HEAD_TAGHead tag.private static String__META_CONTENT_ATTRMeta content attribute name.private static String__META_HTTP_EQUIV_ATTRMeta HTTP equiv attribute name.private static String__META_HTTP_EQUIV_CTYPE_VALUEMeta HTTP equiv attribute value for content type.private static String__META_TAGMeta tag.private static Set<String>__NAMESPACES_ALLOWEDList of the tags to collapse.private static String__SCRIPT_TAGScript tag.private static String__STYLE_TAGStyle tag.private StringBuilder_bufferBuffer to store script tag content.private boolean_disableOutputEscapingFlag for disabling output escaping states encountered withjavax.xml.transform.*-output-escapingprocessing instructions.private int_insideFilteredTagInside filtered tag: greater than 0 if we are inside a filtered tag.private int_insideInlineResourceTagInline resource context: greater than 0 if we are inside a style or a script tag.private boolean_isMetaContentTypeMeta http-equiv="Content-Type" context.private Logger_loggerprivate Set<String>_namespacesAllowedNamespaces allowed.private Set<String>_namespacesPrefixFilteredNamespaces prefixe filtered.private boolean_omitXmlDeclarationDefine whether to put XML declaration in the head of the document.private int_tagsInsideInlineResourceTagprivate Set<String>_tagsToCollapseBuffer to store tag to collapse.protected XHTMLSerializerExtensionPoint_xhtmlSerializerExtensionPointThe XHTMLSerializerExtensionPoint instance-
Fields inherited from class org.apache.cocoon.components.serializers.XHTMLSerializer
doctype_default, encodeCharacters, XHTML1_DOCTYPE_FRAMESET, XHTML1_DOCTYPE_STRICT, XHTML1_DOCTYPE_TRANSITIONAL, XHTML1_NAMESPACE, XHTML5_DOCTYPE
-
Fields inherited from class org.apache.cocoon.components.serializers.XMLSerializer
doctype
-
Fields inherited from class org.apache.cocoon.components.serializers.EncodingSerializer
ATTRIBUTE_LENGTH, ATTRIBUTE_LOCAL, ATTRIBUTE_NSURI, ATTRIBUTE_QNAME, ATTRIBUTE_VALUE, charset, indentPerLevel, namespaces
-
Fields inherited from interface org.apache.cocoon.serialization.Serializer
ROLE
-
-
Constructor Summary
Constructors Constructor Description XHTMLSerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Attributes_filterAttributes(Attributes attributes)voidcharacters(char[] ch, int start, int length)voidcharactersImpl(char[] data, int start, int length)voidcomment(char[] data, int start, int length)voidconfigure(Configuration conf)voidenableLogging(Logger logger)voidendElement(String nsuri, String local, String qual)voidendElementImpl(String uri, String local, String qual)voidendPrefixMapping(String prefix)voidignorableWhitespace(char[] data, int start, int length)private booleanisJsScript(String local, String[][] attributes)private booleanisMetaContentType(String local, String[][] attributes)voidprocessingInstruction(String target, String data)voidrecycle()voidservice(ServiceManager manager)voidstartElement(String nsuri, String local, String qual, Attributes attributes)voidstartElementImpl(String uri, String local, String qual, String[][] lNamespaces, String[][] attributes)voidstartPrefixMapping(String prefix, String uri)-
Methods inherited from class org.apache.cocoon.components.serializers.XHTMLSerializer
body, encode, getMimeType, head, isCdataElement
-
Methods inherited from class org.apache.cocoon.components.serializers.XMLSerializer
closeElement, endCDATA, endDocument, endDTD, endEntity, skippedEntity, startCDATA, startDocument, startDTD, startEntity
-
Methods inherited from class org.apache.cocoon.components.serializers.EncodingSerializer
encode, encode, flush, getColumnNumber, getLineNumber, getLocation, getPublicId, getSystemId, setDocumentLocator, setOutputStream, shouldSetContentLength, write, write, write, write, write, writeIndent, writeln, writeln
-
-
-
-
Field Detail
-
__NAMESPACES_ALLOWED
private static final Set<String> __NAMESPACES_ALLOWED
List of the tags to collapse.
-
__COLLAPSE_TAGS
private static final Set<String> __COLLAPSE_TAGS
List of the tags to collapse.
-
__HEAD_TAG
private static final String __HEAD_TAG
Head tag.- See Also:
- Constant Field Values
-
__META_TAG
private static final String __META_TAG
Meta tag.- See Also:
- Constant Field Values
-
__META_HTTP_EQUIV_ATTR
private static final String __META_HTTP_EQUIV_ATTR
Meta HTTP equiv attribute name.- See Also:
- Constant Field Values
-
__META_HTTP_EQUIV_CTYPE_VALUE
private static final String __META_HTTP_EQUIV_CTYPE_VALUE
Meta HTTP equiv attribute value for content type.- See Also:
- Constant Field Values
-
__META_CONTENT_ATTR
private static final String __META_CONTENT_ATTR
Meta content attribute name.- See Also:
- Constant Field Values
-
__SCRIPT_TAG
private static final String __SCRIPT_TAG
Script tag.- See Also:
- Constant Field Values
-
__STYLE_TAG
private static final String __STYLE_TAG
Style tag.- See Also:
- Constant Field Values
-
_xhtmlSerializerExtensionPoint
protected XHTMLSerializerExtensionPoint _xhtmlSerializerExtensionPoint
The XHTMLSerializerExtensionPoint instance
-
_buffer
private StringBuilder _buffer
Buffer to store script tag content.
-
_tagsToCollapse
private Set<String> _tagsToCollapse
Buffer to store tag to collapse.
-
_namespacesAllowed
private Set<String> _namespacesAllowed
Namespaces allowed.
-
_namespacesPrefixFiltered
private Set<String> _namespacesPrefixFiltered
Namespaces prefixe filtered.
-
_insideFilteredTag
private int _insideFilteredTag
Inside filtered tag: greater than 0 if we are inside a filtered tag.
-
_insideInlineResourceTag
private int _insideInlineResourceTag
Inline resource context: greater than 0 if we are inside a style or a script tag.
-
_tagsInsideInlineResourceTag
private int _tagsInsideInlineResourceTag
-
_disableOutputEscaping
private boolean _disableOutputEscaping
Flag for disabling output escaping states encountered withjavax.xml.transform.*-output-escapingprocessing instructions.
-
_omitXmlDeclaration
private boolean _omitXmlDeclaration
Define whether to put XML declaration in the head of the document.
-
_isMetaContentType
private boolean _isMetaContentType
Meta http-equiv="Content-Type" context. True if we are inside a meta "content-type" tag.
-
-
Constructor Detail
-
XHTMLSerializer
public XHTMLSerializer()
-
-
Method Detail
-
enableLogging
public void enableLogging(Logger logger)
- Specified by:
enableLoggingin interfaceLogEnabled
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
configure
public void configure(Configuration conf) throws ConfigurationException
- Specified by:
configurein interfaceConfigurable- Overrides:
configurein classXHTMLSerializer- Throws:
ConfigurationException
-
startPrefixMapping
public void startPrefixMapping(String prefix, String uri) throws SAXException
- Specified by:
startPrefixMappingin interfaceContentHandler- Overrides:
startPrefixMappingin classEncodingSerializer- Throws:
SAXException
-
startElement
public void startElement(String nsuri, String local, String qual, Attributes attributes) throws SAXException
- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classEncodingSerializer- Throws:
SAXException
-
_filterAttributes
private Attributes _filterAttributes(Attributes attributes)
-
startElementImpl
public void startElementImpl(String uri, String local, String qual, String[][] lNamespaces, String[][] attributes) throws SAXException
- Overrides:
startElementImplin classXHTMLSerializer- Throws:
SAXException
-
characters
public void characters(char[] ch, int start, int length) throws SAXException
- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classEncodingSerializer- Throws:
SAXException
-
charactersImpl
public void charactersImpl(char[] data, int start, int length) throws SAXException
- Overrides:
charactersImplin classXMLSerializer- Throws:
SAXException
-
ignorableWhitespace
public void ignorableWhitespace(char[] data, int start, int length) throws SAXException
- Specified by:
ignorableWhitespacein interfaceContentHandler- Overrides:
ignorableWhitespacein classXMLSerializer- Throws:
SAXException
-
comment
public void comment(char[] data, int start, int length) throws SAXException
- Specified by:
commentin interfaceLexicalHandler- Overrides:
commentin classXMLSerializer- Throws:
SAXException
-
processingInstruction
public void processingInstruction(String target, String data) throws SAXException
- Specified by:
processingInstructionin interfaceContentHandler- Overrides:
processingInstructionin classXMLSerializer- Throws:
SAXException
-
endElement
public void endElement(String nsuri, String local, String qual) throws SAXException
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classEncodingSerializer- Throws:
SAXException
-
endElementImpl
public void endElementImpl(String uri, String local, String qual) throws SAXException
- Overrides:
endElementImplin classXHTMLSerializer- Throws:
SAXException
-
endPrefixMapping
public void endPrefixMapping(String prefix) throws SAXException
- Specified by:
endPrefixMappingin interfaceContentHandler- Overrides:
endPrefixMappingin classEncodingSerializer- Throws:
SAXException
-
isMetaContentType
private boolean isMetaContentType(String local, String[][] attributes)
-
isJsScript
private boolean isJsScript(String local, String[][] attributes)
-
recycle
public void recycle()
- Specified by:
recyclein interfaceRecyclable- Overrides:
recyclein classXMLSerializer
-
-