nu.staldal.xodus
Class Serializer

java.lang.Object
  extended by nu.staldal.xodus.Serializer
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.ext.LexicalHandler
Direct Known Subclasses:
HTMLSerializer, TextSerializer, XMLSerializer

public abstract class Serializer
extends java.lang.Object
implements org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler, org.xml.sax.DTDHandler, org.xml.sax.ext.DeclHandler

Serialize SAX2 events to its textual XML representation.

Support output to XML, XHTML and Text. Full support for XML namespaces.

The ContentHandler.startDocument() and ContentHandler.endDocument() method must be used.

Output properties controls the serialization process, it uses the keys in javax.xml.transform.OutputKeys.

The METHOD output property must be specified. It can be "xml", "xhtml", "text" or "html".

The CDATA_SECTION_ELEMENTS output property is not supported.

The ENCODING output property defaults to UTF-8 for XML and XHTML, and to ISO-8859-1 for Text and HTML.

The MEDIA_TYPE output property is not used.

The "html" output method does not escape non-ASCII characters in URI attribute values, as specified in the XSLT 1.0 specification.

The "html" output method does not not add any META element with encoding, as specified in the XSLT 1.0 specification.

javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING and javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING can be used as processingInstruction targets to disable output escaping.


Field Summary
protected  XMLCharacterEncoder out
           
protected  OutputConfig outputConfig
           
protected  java.lang.String systemId
           
 
Constructor Summary
protected Serializer(javax.xml.transform.stream.StreamResult result, OutputConfig outputConfig)
           
 
Method Summary
static Serializer createSerializer(javax.xml.transform.stream.StreamResult result, java.util.Properties outputProperties)
          Factory method, create a new Serializer.
protected  void finishOutput()
          Finish writing to output.
protected  void newline()
          Write a newline.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 
Methods inherited from interface org.xml.sax.DTDHandler
notationDecl, unparsedEntityDecl
 
Methods inherited from interface org.xml.sax.ext.DeclHandler
attributeDecl, elementDecl, externalEntityDecl, internalEntityDecl
 

Field Detail

outputConfig

protected final OutputConfig outputConfig

systemId

protected final java.lang.String systemId

out

protected final XMLCharacterEncoder out
Constructor Detail

Serializer

protected Serializer(javax.xml.transform.stream.StreamResult result,
                     OutputConfig outputConfig)
              throws java.lang.IllegalArgumentException,
                     java.io.IOException,
                     java.io.UnsupportedEncodingException
Throws:
java.lang.IllegalArgumentException
java.io.IOException
java.io.UnsupportedEncodingException
Method Detail

createSerializer

public static Serializer createSerializer(javax.xml.transform.stream.StreamResult result,
                                          java.util.Properties outputProperties)
                                   throws java.lang.IllegalArgumentException,
                                          java.io.IOException,
                                          java.io.UnsupportedEncodingException
Factory method, create a new Serializer.

Parameters:
result - specifies where to write the textual representation.
outputProperties - output properties, uses OutputKeys
Returns:
a new Serializer
Throws:
java.io.UnsupportedEncodingException - if the ENCODING output property is invalid.
java.lang.IllegalArgumentException - if any other output property is invalid.
java.io.IOException - if the result is invalid.

finishOutput

protected void finishOutput()
                     throws java.io.IOException
Finish writing to output. Does not close output if an OutputStream or Writer was provided.

Throws:
java.io.IOException

newline

protected void newline()
                throws java.io.IOException
Write a newline.

Throws:
java.io.IOException