apache > cocoon
 

HTML Serializer

HTML Serializer

The HTML serializer serializes xml content to html. It is the default serializer.

  • Name : html
  • Class: org.apache.cocoon.serialization.HtmlSerializer
  • Cacheable: yes.

Sitemap Configuration

The HTML Serializer is declared in the sitemap serializers section.

<map:serializers default="html">
...
  <map:serializer name="html"
    src="org.apache.cocoon.serialization.HTMLSerializer"
    mime-type="text/html"  
    logger="sitemap.serializer.html" 
    pool-max="32">
    <!-- serializer configurations -->
...    
  </map:serializer>
...
        

HTML Serializer can be configured, specifying elements inside of the <map:serializer> body.

Configuration Example

The following HTML Serializer snippet is setting doctype, and encoding configuration for the HTML Serializer

<map:serializer name="html"         
  src="org.apache.cocoon.serialization.HTMLSerializer"
  mime-type="text/html">
  <doctype-public>-//W3C//DTD HTML 4.01 Transitional//EN</doctype-public>
  <encoding>ISO-8859-1</encoding>
</map:serializer>
          

This configuration will result in HTML output of the form

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title...
...
          

The HTML Serializer accepts following configuration parameters. These configurations are not Xalan specific.

Name

Xalan Default Value

Comment

cdata-section-elements

none

cdata-section-elements

specifies a whitespace delimited list of the names of elements whose text node children should be output using CDATA sections. See section 16 of the XSL Transformations (XSLT) W3C Recommendation.

doctype-public

none

doctype-public

specifies the public identifier to be used in the document type declaration.

doctype-system

none

doctype-system specifies the system identifier to be used in the document type declaration. See section 16 of the XSL Transformations (XSLT) W3C Recommendation

encoding

none

encoding

specifies the preferred character encoding that the Transformer should use to encode sequences of characters as sequences of bytes. The value of the attribute should be treated case-insensitively. The value must only contain characters in the range #x21 to #x7E (i.e., printable ASCII characters). The value should either be a charset registered with the Internet Assigned Numbers Authority [IANA], [RFC2278] or start with X-. See section 16 of the XSL Transformations (XSLT) W3C Recommendation

indent

yes

A Flag for toggling indent. This flag toggles only if some elements should trigger a line break.

media-type

media-type specifies the media type (MIME content type) of the data that results from outputting the result tree. The charset parameter should not be specified explicitly; instead, when the top-level media type is text, a charset parameter should be added according to the character encoding actually used by the output method. See section 16 of the XSL Transformations (XSLT) W3C Recommendation

method

The method attribute identifies the overall method that should be used for outputting the result tree. Other non-namespaced values may be used, such as "xhtml", but, if accepted, the handling of such values is implementation defined. If any of the method values are not accepted and are not namespace qualified, then {@link javax.xml.transform.Transformer#setOutputProperty} or {@link javax.xml.transform.Transformer#setOutputProperties} will throw a {@link java.lang.IllegalArgumentException}. See section 16 of the XSL Transformations (XSLT) W3C Recommendation

omit-xml-declaration

omit-xml-declaration specifies whether the XSLT processor should output an XML declaration; the value must be yes or no. See section 16 of the XSL Transformations (XSLT) W3C Recommendation

standalone

standalone specifies whether the Transformer should output a standalone document declaration; the value must be yes or no. See section 16 of the XSL Transformations (XSLT) W3C Recommendation

version

version specifies the version of the output method. When the output method is "xml", the version value specifies the version of XML to be used for outputting the result tree. The default value for the xml output method is 1.0. When the output method is "html", the version value indicates the version of the HTML. The default value for the xml output method is 4.0, which specifies that the result should be output as HTML conforming to the HTML 4.0 Recommendation [HTML]. If the output method is "text", the version property is ignored. See section 16 of the XSL Transformations (XSLT) W3C Recommendation

Note
Former property buffer-size is deprecated, and is ignored.

The HTML Serializer sets the method property to html.

Pipeline Usage

...
<map:match pattern="*.html">
<map:generate...
...
<map:serialize type="html"/>
...
      

Further Reading