org.apache.cocoon.components.serializers
Class XMLSerializer

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

public class XMLSerializer
extends EncodingSerializer

A fancy XML serializer not relying on the JAXP API.

For configuration options of this serializer, please look at the EncodingSerializer.

Version:
CVS $Id: XMLSerializer.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Field Summary
protected  DocType doctype
          The DocType instance representing the document.
 
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
  XMLSerializer()
          Create a new instance of this XMLSerializer
protected XMLSerializer(XMLEncoder encoder)
          Create a new instance of this XMLSerializer
 
Method Summary
 void body(String uri, String local, String qual)
          Receive notification of the beginning of the document body.
 void charactersImpl(char[] data, int start, int length)
          Receive notification of character data.
protected  boolean closeElement(boolean end_element)
          Write the end part of a start element (if necessary).
 void comment(char[] data, int start, int length)
          Report an XML comment anywhere in the document.
 void endCDATA()
          Report the end of a CDATA section.
 void endDocument()
          Receive notification of the end of a document.
 void endDTD()
          Report the start of DTD declarations, if any.
 void endElementImpl(String uri, String local, String qual)
          Receive notification of the end of an element.
 void endEntity(String name)
          Report the end of an entity.
 String getMimeType()
          Return the MIME Content-Type produced by this serializer.
protected  void head()
          Write the XML document header.
 void ignorableWhitespace(char[] data, int start, int length)
          Receive notification of ignorable whitespace in element content.
 void processingInstruction(String target, String data)
          Receive notification of a processing instruction.
 void recycle()
          Reset this XMLSerializer.
 void skippedEntity(String name)
          Receive notification of a skipped entity.
 void startCDATA()
          Report the start of a CDATA section.
 void startDocument()
          Receive notification of the beginning of a document.
 void startDTD(String name, String public_id, String system_id)
          Report the start of DTD declarations, if any.
 void startElementImpl(String uri, String local, String qual, String[][] namespaces, String[][] attributes)
          Receive notification of the beginning of an element.
 void startEntity(String name)
          Report the beginning of some internal and external XML entities.
 
Methods inherited from class org.apache.cocoon.components.serializers.EncodingSerializer
characters, configure, 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

doctype

protected DocType doctype
The DocType instance representing the document.

Constructor Detail

XMLSerializer

public XMLSerializer()
Create a new instance of this XMLSerializer


XMLSerializer

protected XMLSerializer(XMLEncoder encoder)
Create a new instance of this XMLSerializer

Method Detail

recycle

public void recycle()
Reset this XMLSerializer.

Specified by:
recycle in interface Recyclable
Overrides:
recycle in class EncodingSerializer

getMimeType

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

See Also:
AbstractProcessingPipeline.setMimeTypeForSerializer(org.apache.cocoon.environment.Environment), AbstractProcessingPipeline.setMimeTypeForReader(org.apache.cocoon.environment.Environment)

startDocument

public void startDocument()
                   throws SAXException
Receive notification of the beginning of a document.

Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class EncodingSerializer
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Receive notification of the end of a document.

Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class EncodingSerializer
Throws:
SAXException

head

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

This method will write out the <?xml version="1.0" ...> header.

Throws:
SAXException

startDTD

public void startDTD(String name,
                     String public_id,
                     String system_id)
              throws SAXException
Report the start of DTD declarations, if any.

Throws:
SAXException

endDTD

public void endDTD()
            throws SAXException
Report the start of DTD declarations, if any.

Throws:
SAXException

body

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

Specified by:
body in class EncodingSerializer
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.

Specified by:
startElementImpl in class EncodingSerializer
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.

Specified by:
endElementImpl in class EncodingSerializer
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

closeElement

protected boolean closeElement(boolean end_element)
                        throws SAXException
Write the end part of a start element (if necessary).

Parameters:
end_element - Whether this method was called because an element is being closed or not.
Returns:
true if this call successfully closed the element (and no further </element> is required.
Throws:
SAXException

startCDATA

public void startCDATA()
                throws SAXException
Report the start of a CDATA section.

Throws:
SAXException

endCDATA

public void endCDATA()
              throws SAXException
Report the end of a CDATA section.

Throws:
SAXException

charactersImpl

public void charactersImpl(char[] data,
                           int start,
                           int length)
                    throws SAXException
Receive notification of character data.

Specified by:
charactersImpl in class EncodingSerializer
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] data,
                                int start,
                                int length)
                         throws SAXException
Receive notification of ignorable whitespace in element content.

Throws:
SAXException

comment

public void comment(char[] data,
                    int start,
                    int length)
             throws SAXException
Report an XML comment anywhere in the document.

Throws:
SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Receive notification of a processing instruction.

Throws:
SAXException

startEntity

public void startEntity(String name)
                 throws SAXException
Report the beginning of some internal and external XML entities.

Throws:
SAXException

endEntity

public void endEntity(String name)
               throws SAXException
Report the end of an entity.

Throws:
SAXException

skippedEntity

public void skippedEntity(String name)
                   throws SAXException
Receive notification of a skipped entity.

Throws:
SAXException


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.