org.apache.xml.serialize

Class TextSerializer

public class TextSerializer extends BaseMarkupSerializer

Implements a text serializer supporting both DOM and SAX serializing. For usage instructions see {@link Serializer}.

If an output stream is used, the encoding is taken from the output format (defaults to UTF-8). If a writer is used, make sure the writer uses the same encoding (if applies) as specified in the output format.

The serializer supports both DOM and SAX. DOM serializing is done by calling {@link #serialize} and SAX serializing is done by firing SAX events and using the serializer as a document handler.

If an I/O exception occurs while serializing, the serializer will not throw an exception directly, but only throw it at the end of serializing (either DOM or SAX's {@link org.xml.sax.DocumentHandler#endDocument}.

Version: $Revision: 1.14 $ $Date: 2004/02/24 23:34:03 $

Author: Assaf Arkin

See Also: Serializer

Constructor Summary
TextSerializer()
Constructs a new serializer.
Method Summary
voidcharacters(char[] chars, int start, int length)
protected voidcharacters(String text, boolean unescaped)
voidcomment(String text)
voidcomment(char[] chars, int start, int length)
protected ElementStatecontent()
voidendElement(String namespaceURI, String localName, String rawName)
voidendElement(String tagName)
voidendElementIO(String tagName)
protected StringgetEntityRef(int ch)
voidprocessingInstructionIO(String target, String code)
protected voidserializeElement(Element elem)
Called to serialize a DOM element.
protected voidserializeNode(Node node)
Serialize the DOM node.
voidsetOutputFormat(OutputFormat format)
protected voidstartDocument(String rootTagName)
Called to serialize the document's DOCTYPE by the root element.
voidstartElement(String namespaceURI, String localName, String rawName, Attributes attrs)
voidstartElement(String tagName, AttributeList attrs)

Constructor Detail

TextSerializer

public TextSerializer()
Constructs a new serializer. The serializer cannot be used without calling {@link #setOutputCharStream} or {@link #setOutputByteStream} first.

Method Detail

characters

public void characters(char[] chars, int start, int length)

characters

protected void characters(String text, boolean unescaped)

comment

public void comment(String text)

comment

public void comment(char[] chars, int start, int length)

content

protected ElementState content()

endElement

public void endElement(String namespaceURI, String localName, String rawName)

endElement

public void endElement(String tagName)

endElementIO

public void endElementIO(String tagName)

getEntityRef

protected String getEntityRef(int ch)

processingInstructionIO

public void processingInstructionIO(String target, String code)

serializeElement

protected void serializeElement(Element elem)
Called to serialize a DOM element. Equivalent to calling {@link #startElement}, {@link #endElement} and serializing everything inbetween, but better optimized.

serializeNode

protected void serializeNode(Node node)
Serialize the DOM node. This method is unique to the Text serializer.

Parameters: node The node to serialize

setOutputFormat

public void setOutputFormat(OutputFormat format)

startDocument

protected void startDocument(String rootTagName)
Called to serialize the document's DOCTYPE by the root element.

This method will check if it has not been called before ({@link #_started}), will serialize the document type declaration, and will serialize all pre-root comments and PIs that were accumulated in the document (see {@link #serializePreRoot}). Pre-root will be serialized even if this is not the first root element of the document.

startElement

public void startElement(String namespaceURI, String localName, String rawName, Attributes attrs)

startElement

public void startElement(String tagName, AttributeList attrs)
Copyright B) 1999-2005 Apache XML Project. All Rights Reserved.