org.apache.xml.serializer

## Interface SerializationHandler

All Superinterfaces:
  ContentHandler, DeclHandler, DOMSerializer, DTDHandler, ErrorHandler, ExtendedContentHandler, ExtendedLexicalHandler, LexicalHandler, Serializer

All Known Implementing Classes:
  AdaptiveResultTreeImpl, EmptySerializer, SerializerBase, SimpleResultTreeImpl, StringValueHandler, ToHTMLSAXHandler, ToHTMLStream, ToSAXHandler, ToStream, ToTextSAXHandler, ToTextStream, ToUnknownStream, ToXMLSAXHandler, ToXMLStream

    public interface SerializationHandler
    extends ExtendedContentHandler, ExtendedLexicalHandler, DeclHandler, DTDHandler, ErrorHandler, DOMSerializer, Serializer

This interface is the one that a serializer implements. It is a group of other interfaces, such as ExtendedContentHandler, ExtendedLexicalHandler etc. In addition there are other methods, such as reset(). This class is public only because it is used in another package, it is not a public API.

Usage:
  **For internal use only**

### Field Summary

### Fields inherited from interface org.apache.xml.serializer.ExtendedContentHandler

`HTML_ATTREMPTY, HTML_ATTRURL, NO_BAD_CHARS`

### Method Summary

Methods
`void` `close()`
`void` `flushPending()` A SerializationHandler accepts SAX-like events, so it can accumulate attributes or namespace nodes after a startElement().
`java.lang.String` `getDoctypePublic()` Returns the previously set value of the value to be used as the public identifier in the document type declaration (DTD).
`java.lang.String` `getDoctypeSystem()` Returns the previously set value of the value to be used as the system identifier in the document type declaration (DTD).
`java.lang.String` `getEncoding()`
`boolean` `getIndent()`
`int` `getIndentAmount()`
`java.lang.String` `getMediaType()`
`boolean` `getOmitXMLDeclaration()`
`java.lang.String` `getOutputProperty(java.lang.String name)` Get the value for a property that affects seraialization, if a property was set return that value, otherwise return the default value, otherwise return null.
`java.lang.String` `getOutputPropertyDefault(java.lang.String name)` Get the default value for a property that affects seraialization, or null if there is none.
`java.lang.String` `getStandalone()`
`Transformer` `getTransformer()` Get the transformer associated with the serializer.
`java.lang.String` `getVersion()`
`void` `serialize(Node node)` Notify that the serializer should take this DOM node as input to be serialized.
`void` `setCdataSectionElements(java.util.Vector URI_and_localNames)` Sets the value coming from the xsl:output cdata-section-elements stylesheet property.
`void` `setContentHandler(ContentHandler ch)` Set the SAX Content handler that the serializer sends its output to.
`void` `setDoctype(java.lang.String system, java.lang.String pub)` Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
`void` `setDoctypePublic(java.lang.String doctype)` Set the value coming from the xsl:output doctype-public stylesheet attribute.
`void` `setDoctypeSystem(java.lang.String doctype)` Set the value coming from the xsl:output doctype-system stylesheet attribute.
`void` `setDTDEntityExpansion(boolean expand)` Default behavior is to expand DTD entities, that is the initall default value is true.
`void` `setEncoding(java.lang.String encoding)` Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
`boolean` `setEscaping(boolean escape)` Turns special character escaping on/off.
`void` `setIndent(boolean indent)` Sets the value coming from the xsl:output indent stylesheet attribute.
`void` `setIndentAmount(int spaces)` Set the number of spaces to indent for each indentation level.
`void` `setMediaType(java.lang.String mediatype)` Sets the value coming from the xsl:output media-type stylesheet attribute.
`void` `setNamespaceMappings(NamespaceMappings mappings)` Used only by TransformerSnapshotImpl to restore the serialization to a previous state.
`void` `setOmitXMLDeclaration(boolean b)` Sets the value coming from the xsl:output omit-xml-declaration stylesheet attribute
`void` `setOutputProperty(java.lang.String name, java.lang.String val)` Set the non-default value for a property that affects seraialization.
`void` `setOutputPropertyDefault(java.lang.String name, java.lang.String val)` Set the default value for a property that affects seraialization.
`void` `setStandalone(java.lang.String standalone)` Sets the value coming from the xsl:output standalone stylesheet attribute.
`void` `setTransformer(Transformer transformer)` Set the transformer associated with the serializer.
`void` `setVersion(java.lang.String version)` Sets the value coming from the xsl:output version attribute.

### Methods inherited from interface org.apache.xml.serializer.ExtendedContentHandler

`addAttribute, addAttribute, addAttribute, addAttributes, addUniqueAttribute, addXSLAttribute, characters, characters, endElement, entityReference, getNamespaceMappings, getNamespaceURI, getNamespaceURIFromPrefix, getPrefix, namespaceAfterStartElement, setSourceLocator, startElement, startElement, startPrefixMapping`

### Methods inherited from interface org.xml.sax.ContentHandler

`characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping`

### Methods inherited from interface org.apache.xml.serializer.ExtendedLexicalHandler

`comment`

### Methods inherited from interface org.xml.sax.ext.LexicalHandler

`comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity`

### Methods inherited from interface org.xml.sax.ext.DeclHandler

`attributeDecl, elementDecl, externalEntityDecl, internalEntityDecl`

### Methods inherited from interface org.xml.sax.DTDHandler

`notationDecl, unparsedEntityDecl`

### Methods inherited from interface org.xml.sax.ErrorHandler

`error, fatalError, warning`

### Methods inherited from interface org.apache.xml.serializer.Serializer

`asContentHandler, asDOM3Serializer, asDOMSerializer, getOutputFormat, getOutputStream, getWriter, reset, setOutputFormat, setOutputStream, setWriter`

### Method Detail

#### setContentHandler

    void setContentHandler(ContentHandler ch)

Set the SAX Content handler that the serializer sends its output to. This method only applies to a ToSAXHandler, not to a ToStream serializer.

See Also:
  `Serializer.asContentHandler()`, `ToSAXHandler`

#### close

    void close()

#### serialize

    void serialize(Node node)
                   throws java.io.IOException

Notify that the serializer should take this DOM node as input to be serialized.

Specified by:
  `serialize` in interface `DOMSerializer`
Parameters:
  `node` - the DOM node to be serialized.
Throws:
  `java.io.IOException`

#### setEscaping

    boolean setEscaping(boolean escape)
                        throws SAXException

Turns special character escaping on/off. Note that characters will never, even if this option is set to 'true', be escaped within CDATA sections in output XML documents.

Parameters:
  `escape` - true if escaping is to be set on.
Throws:
  `SAXException`

#### setIndentAmount

    void setIndentAmount(int spaces)

Set the number of spaces to indent for each indentation level.

Parameters:
  `spaces` - the number of spaces to indent for each indentation level.

#### setTransformer

    void setTransformer(Transformer transformer)

Set the transformer associated with the serializer.

Parameters:
  `transformer` - the transformer associated with the serializer.

#### getTransformer

    Transformer getTransformer()

Get the transformer associated with the serializer.

Returns:
  Transformer the transformer associated with the serializer.

#### setNamespaceMappings

    void setNamespaceMappings(NamespaceMappings mappings)

Used only by TransformerSnapshotImpl to restore the serialization to a previous state.

Parameters:
  `mappings` - NamespaceMappings

#### flushPending

    void flushPending()
                      throws SAXException

A SerializationHandler accepts SAX-like events, so it can accumulate attributes or namespace nodes after a startElement().

If the SerializationHandler has a Writer or OutputStream, a call to this method will flush such accumulated events as a closed start tag for an element.

If the SerializationHandler wraps a ContentHandler, a call to this method will flush such accumulated events as a SAX (not SAX-like) calls to startPrefixMapping() and startElement().

If one calls endDocument() then one need not call this method since a call to endDocument() will do what this method does. However, in some circumstances, such as with document fragments, endDocument() is not called and it may be necessary to call this method to flush any pending events.

For performance reasons this method should not be called very often.

Throws:
  `SAXException`

#### setDTDEntityExpansion

    void setDTDEntityExpansion(boolean expand)

Default behavior is to expand DTD entities, that is the initall default value is true.

Parameters:
  `expand` - true if DTD entities are to be expanded, false if they are to be left as DTD entity references.

#### getDoctypePublic

    java.lang.String getDoctypePublic()

Returns the previously set value of the value to be used as the public identifier in the document type declaration (DTD).

Returns:
  the public identifier to be used in the DOCTYPE declaration in the output document.

#### getDoctypeSystem

    java.lang.String getDoctypeSystem()

Returns the previously set value of the value to be used as the system identifier in the document type declaration (DTD).

Returns:
  the system identifier to be used in the DOCTYPE declaration in the output document.

#### getEncoding

    java.lang.String getEncoding()

Returns:
  the character encoding to be used in the output document.

#### getIndent

    boolean getIndent()

Returns:
  true if the output document should be indented to visually indicate its structure.

#### getIndentAmount

    int getIndentAmount()

Returns:
  the number of spaces to indent for each indentation level.

#### getMediaType

    java.lang.String getMediaType()

Returns:
  the mediatype the media-type or MIME type associated with the output document.

#### getOmitXMLDeclaration

    boolean getOmitXMLDeclaration()

Returns:
  true if the XML declaration is to be omitted from the output document.

#### getStandalone

    java.lang.String getStandalone()

Returns:
  a value of "yes" if the `standalone` delaration is to be included in the output document.

#### getVersion

    java.lang.String getVersion()

Returns:
  the version of the output format.

#### setCdataSectionElements

    void setCdataSectionElements(java.util.Vector URI_and_localNames)

Sets the value coming from the xsl:output cdata-section-elements stylesheet property. This sets the elements whose text elements are to be output as CDATA sections.

Parameters:
  `URI_and_localNames` - pairs of namespace URI and local names that identify elements whose text elements are to be output as CDATA sections. The namespace of the local element must be the given URI to match. The qName is not given because the prefix does not matter, only the namespace URI to which that prefix would map matters, so the prefix itself is not relevant in specifying which elements have their text to be output as CDATA sections.

#### setDoctype

    void setDoctype(java.lang.String system,
                  java.lang.String pub)

Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties

Parameters:
  `system` - the system identifier to be used in the DOCTYPE declaration in the output document.
  `pub` - the public identifier to be used in the DOCTYPE declaration in the output document.

#### setDoctypePublic

    void setDoctypePublic(java.lang.String doctype)

Set the value coming from the xsl:output doctype-public stylesheet attribute.

Parameters:
  `doctype` - the public identifier to be used in the DOCTYPE declaration in the output document.

#### setDoctypeSystem

    void setDoctypeSystem(java.lang.String doctype)

Set the value coming from the xsl:output doctype-system stylesheet attribute.

Parameters:
  `doctype` - the system identifier to be used in the DOCTYPE declaration in the output document.

#### setEncoding

    void setEncoding(java.lang.String encoding)

Sets the character encoding coming from the xsl:output encoding stylesheet attribute.

Parameters:
  `encoding` - the character encoding

#### setIndent

    void setIndent(boolean indent)

Sets the value coming from the xsl:output indent stylesheet attribute.

Parameters:
  `indent` - true if the output document should be indented to visually indicate its structure.

#### setMediaType

    void setMediaType(java.lang.String mediatype)

Sets the value coming from the xsl:output media-type stylesheet attribute.

Parameters:
  `mediatype` - the media-type or MIME type associated with the output document.

#### setOmitXMLDeclaration

    void setOmitXMLDeclaration(boolean b)

Sets the value coming from the xsl:output omit-xml-declaration stylesheet attribute

Parameters:
  `b` - true if the XML declaration is to be omitted from the output document.

#### setStandalone

    void setStandalone(java.lang.String standalone)

Sets the value coming from the xsl:output standalone stylesheet attribute.

Parameters:
  `standalone` - a value of "yes" indicates that the `standalone` delaration is to be included in the output document.

#### setVersion

    void setVersion(java.lang.String version)

Sets the value coming from the xsl:output version attribute.

Parameters:
  `version` - the version of the output format.

#### getOutputProperty

    java.lang.String getOutputProperty(java.lang.String name)

Get the value for a property that affects seraialization, if a property was set return that value, otherwise return the default value, otherwise return null.

Parameters:
  `name` - The name of the property, which is just the local name if it is in no namespace, but is the URI in curly braces followed by the local name if it is in a namespace, for example:
  - "encoding"
  - "method"
  - "{http://xml.apache.org/xalan}indent-amount"
  - "{http://xml.apache.org/xalan}line-separator"
Returns:
  The value of the parameter

#### getOutputPropertyDefault

    java.lang.String getOutputPropertyDefault(java.lang.String name)

Get the default value for a property that affects seraialization, or null if there is none. It is possible that a non-default value was set for the property, however the value returned by this method is unaffected by any non-default settings.

Parameters:
  `name` - The name of the property.
Returns:
  The default value of the parameter, or null if there is no default value.

#### setOutputProperty

    void setOutputProperty(java.lang.String name,
                         java.lang.String val)

Set the non-default value for a property that affects seraialization.

Parameters:
  `name` - The name of the property, which is just the local name if it is in no namespace, but is the URI in curly braces followed by the local name if it is in a namespace, for example:
  - "encoding"
  - "method"
  - "{http://xml.apache.org/xalan}indent-amount"
  - "{http://xml.apache.org/xalan}line-separator"

#### setOutputPropertyDefault

    void setOutputPropertyDefault(java.lang.String name,
                                java.lang.String val)

Set the default value for a property that affects seraialization.

Parameters:
  `name` - The name of the property, which is just the local name if it is in no namespace, but is the URI in curly braces followed by the local name if it is in a namespace, for example:
  - "encoding"
  - "method"
  - "{http://xml.apache.org/xalan}indent-amount"
  - "{http://xml.apache.org/xalan}line-separator"