org.apache.cocoon.components.serializers
Class XHTMLSerializer

java.lang.Object
  extended by org.apache.cocoon.components.serializers.EncodingSerializer
      extended by org.apache.cocoon.components.serializers.XMLSerializer
          extended by org.apache.cocoon.components.serializers.XHTMLSerializer
All Implemented Interfaces:
Poolable, Recyclable, Component, Configurable, Serializer, SitemapOutputComponent, XMLConsumer, ContentHandler, LexicalHandler, Locator
Direct Known Subclasses:
HTMLSerializer

public class XHTMLSerializer
extends XMLSerializer

A pedantinc XHTML serializer encoding all recognized entities with their proper HTML names.

For configuration options of this serializer, please look at the EncodingSerializer, in addition to those, this serializer also support the specification of a default doctype. This default will be used if no document type is received in the SAX events, and can be configured in the following way:

 <serializer class="org.apache.cocoon.components.serializers..." ... >
   <doctype-default>mytype</doctype-default>
 </serializer>
 

The value mytype can be one of:

"none"
Not to emit any dococument type declaration.
"strict"
The XHTML 1.0 Strict document type.
"loose"
The XHTML 1.0 Transitional document type.
"frameset"
The XHTML 1.0 Frameset document type.

Version:
CVS $Id: XHTMLSerializer.java 433543 2006-08-22 06:22:54Z crossley $

Field Summary
protected  DocType doctype_default
          The DocType instance representing the document.
static DocType XHTML1_DOCTYPE_FRAMESET
          A representation of the XHTML 1.0 frameset document type.
static DocType XHTML1_DOCTYPE_STRICT
          A representation of the XHTML 1.0 strict document type.
static DocType XHTML1_DOCTYPE_TRANSITIONAL
          A representation of the XHTML 1.0 transitional document type.
static String XHTML1_NAMESPACE
          The namespace URI for XHTML 1.0.
 
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
  XHTMLSerializer()
          Create a new instance of this XHTMLSerializer
protected XHTMLSerializer(XHTMLEncoder encoder)
          Create a new instance of this XHTMLSerializer
 
Method Summary
 void body(String uri, String local, String qual)
          Receive notification of the beginning of the document body.
 void configure(Configuration conf)
          Configure this instance by selecting the default document type to use.
 void endElementImpl(String uri, String local, String qual)
          Receive notification of the end of an element.
 String getMimeType()
          Return the MIME Content-Type produced by this serializer.
protected  void head()
          Write the XML document header.
 void startElementImpl(String uri, String local, String qual, String[][] namespaces, String[][] attributes)
          Receive notification of the beginning of an element.
 
Methods inherited from class org.apache.cocoon.components.serializers.XMLSerializer
charactersImpl, closeElement, comment, endCDATA, endDocument, endDTD, endEntity, ignorableWhitespace, processingInstruction, recycle, skippedEntity, startCDATA, startDocument, startDTD, startEntity
 
Methods inherited from class org.apache.cocoon.components.serializers.EncodingSerializer
characters, encode, encode, encode, endElement, endPrefixMapping, flush, getColumnNumber, getLineNumber, getLocation, getPublicId, getSystemId, setDocumentLocator, setOutputStream, shouldSetContentLength, startElement, startPrefixMapping, write, write, write, write, write, writeIndent, writeln, writeln
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XHTML1_NAMESPACE

public static final String XHTML1_NAMESPACE
The namespace URI for XHTML 1.0.

See Also:
Constant Field Values

XHTML1_DOCTYPE_STRICT

public static final DocType XHTML1_DOCTYPE_STRICT
A representation of the XHTML 1.0 strict document type.


XHTML1_DOCTYPE_TRANSITIONAL

public static final DocType XHTML1_DOCTYPE_TRANSITIONAL
A representation of the XHTML 1.0 transitional document type.


XHTML1_DOCTYPE_FRAMESET

public static final DocType XHTML1_DOCTYPE_FRAMESET
A representation of the XHTML 1.0 frameset document type.


doctype_default

protected DocType doctype_default
The DocType instance representing the document.

Constructor Detail

XHTMLSerializer

public XHTMLSerializer()
Create a new instance of this XHTMLSerializer


XHTMLSerializer

protected XHTMLSerializer(XHTMLEncoder encoder)
Create a new instance of this XHTMLSerializer

Method Detail

getMimeType

public String getMimeType()
Return the MIME Content-Type produced by this serializer.

Specified by:
getMimeType in interface SitemapOutputComponent
Overrides:
getMimeType in class XMLSerializer
See Also:
AbstractProcessingPipeline.setMimeTypeForSerializer(org.apache.cocoon.environment.Environment), AbstractProcessingPipeline.setMimeTypeForReader(org.apache.cocoon.environment.Environment)

configure

public void configure(Configuration conf)
               throws ConfigurationException
Configure this instance by selecting the default document type to use.

Specified by:
configure in interface Configurable
Overrides:
configure in class EncodingSerializer
Throws:
ConfigurationException

head

protected void head()
             throws SAXException
Write the XML document header.

This method will write out the <?xml version="1.0" ...> header unless omit-xml-declaration is set.

Overrides:
head in class XMLSerializer
Throws:
SAXException

body

public void body(String uri,
                 String local,
                 String qual)
          throws SAXException
Receive notification of the beginning of the document body.

Overrides:
body in class XMLSerializer
Parameters:
uri - The namespace URI of the root element.
local - The local name of the root element.
qual - The fully-qualified name of the root element.
Throws:
SAXException

startElementImpl

public void startElementImpl(String uri,
                             String local,
                             String qual,
                             String[][] namespaces,
                             String[][] attributes)
                      throws SAXException
Receive notification of the beginning of an element.

Overrides:
startElementImpl in class XMLSerializer
Parameters:
uri - The namespace URI of the root element.
local - The local name of the root element.
qual - The fully-qualified name of the root element.
namespaces - An array of String objects containing the namespaces to be declared by this element.
attributes - An array of String objects containing all attributes of this element.
Throws:
SAXException

endElementImpl

public void endElementImpl(String uri,
                           String local,
                           String qual)
                    throws SAXException
Receive notification of the end of an element.

Overrides:
endElementImpl in class XMLSerializer
Parameters:
uri - The namespace URI of the root element.
local - The local name of the root element.
qual - The fully-qualified name of the root element.
Throws:
SAXException


Copyright ? 1999-2007 The Apache Software Foundation. All Rights Reserved.