org.apache.xml.serializer

Class ToSAXHandler

Implemented Interfaces:
org.xml.sax.ContentHandler, DeclHandler, org.xml.sax.DTDHandler, ErrorHandler, DOMSerializer, org.apache.xml.serializer.ExtendedContentHandler, org.apache.xml.serializer.ExtendedLexicalHandler, org.xml.sax.ext.LexicalHandler, SerializationHandler, Serializer, org.apache.xml.serializer.SerializerConstants, org.apache.xml.serializer.XSLOutputAttributes
Known Direct Subclasses:
ToHTMLSAXHandler, ToTextSAXHandler, ToXMLSAXHandler

public abstract class ToSAXHandler
extends SerializerBase

This class is used to provide a base behavior to be inherited by other To...SAXHandler serializers. This class is not a public API.

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

HTML_ATTREMPTY, HTML_ATTRURL, NO_BAD_CHARS

Fields inherited from interface org.apache.xml.serializer.SerializerConstants

CDATA_CONTINUE, CDATA_DELIMITER_CLOSE, CDATA_DELIMITER_OPEN, DEFAULT_SAX_SERIALIZER, EMPTYSTRING, ENTITY_AMP, ENTITY_CRLF, ENTITY_GT, ENTITY_LT, ENTITY_QUOT, XMLNS_PREFIX, XMLNS_URI, XMLVERSION10, XMLVERSION11, XML_PREFIX

Constructor Summary

ToSAXHandler()
ToSAXHandler(ContentHandler hdlr, LexicalHandler lex, String encoding)
ToSAXHandler(ContentHandler handler, String encoding)

Method Summary

void
addUniqueAttribute(String qName, String value, int flags)
Add a unique attribute
void
characters(String characters)
Receive notification of character data.
void
characters(org.w3c.dom.Node node)
This method gets the node's value as a String and uses that String as if it were an input character notification.
void
comment(String comment)
Receive notification of a comment.
void
error(SAXParseException exc)
void
fatalError(SAXParseException exc)
void
flushPending()
This method flushes any pending events, which can be startDocument() closing the opening tag of an element, or closing an open CDATA section.
void
processingInstruction(String target, String data)
Do nothing as this is an abstract class.
boolean
reset()
Try's to reset the super class and reset this class for re-use, so that you don't need to create a new serializer (mostly for performance reasons).
void
setCdataSectionElements(Vector URI_and_localNames)
Does nothing.
void
setContentHandler(ContentHandler _saxHandler)
Sets the SAX ContentHandler.
void
setLexHandler(LexicalHandler _lexHandler)
Sets the LexicalHandler.
void
setShouldOutputNSAttr(boolean doOutputNSAttr)
Set whether or not namespace declarations (e.g.
void
setTransformState(TransformStateSetter ts)
Pass in a reference to a TransformState object, which can be used during SAX ContentHandler events to obtain information about he state of the transformation.
void
startDTD(String arg0, String arg1, String arg2)
Do nothing.
void
startElement(String qName)
An element starts, but attributes are not fully known yet.
void
startElement(String uri, String localName, String qName)
Receives notification that an element starts, but attributes are not fully known yet.
void
startElement(String arg0, String arg1, String arg2, Attributes arg3)
Receive notification of the beginning of an element, although this is a SAX method additional namespace or attribute information can occur before or after this call, that is associated with this element.
void
warning(SAXParseException exc)

Methods inherited from class org.apache.xml.serializer.SerializerBase

addAttribute, addAttribute, addAttribute, addAttributeAlways, addAttributes, addXSLAttribute, asContentHandler, asDOMSerializer, characters, close, comment, endEntity, entityReference, error, fatalError, fireEndEntity, getDoctypePublic, getDoctypeSystem, getEncoding, getIndent, getIndentAmount, getMediaType, getNamespaceMappings, getNamespaceURI, getNamespaceURIFromPrefix, getOmitXMLDeclaration, getPrefix, getStandalone, getTransformer, getVersion, namespaceAfterStartElement, notationDecl, reset, setDTDEntityExpansion, setDoctype, setDoctypePublic, setDoctypeSystem, setDocumentLocator, setEncoding, setIndent, setIndentAmount, setMediaType, setNamespaceMappings, setOmitXMLDeclaration, setSourceLocator, setStandalone, setTransformer, setVersion, startDocument, unparsedEntityDecl, warning

Constructor Details

ToSAXHandler

public ToSAXHandler()

ToSAXHandler

public ToSAXHandler(ContentHandler hdlr,
                    LexicalHandler lex,
                    String encoding)

ToSAXHandler

public ToSAXHandler(ContentHandler handler,
                    String encoding)

Method Details

addUniqueAttribute

public void addUniqueAttribute(String qName,
                               String value,
                               int flags)
            throws SAXException
Add a unique attribute
Specified by:
addUniqueAttribute in interface org.apache.xml.serializer.ExtendedContentHandler

characters

public void characters(String characters)
            throws SAXException
Receive notification of character data.
Specified by:
characters in interface org.apache.xml.serializer.ExtendedContentHandler
Parameters:
characters - The string of characters to process.
See Also:
ExtendedContentHandler.characters(String)

characters

public void characters(org.w3c.dom.Node node)
            throws SAXException
This method gets the node's value as a String and uses that String as if it were an input character notification.
Specified by:
characters in interface org.apache.xml.serializer.ExtendedContentHandler
Overrides:
characters in interface SerializerBase
Parameters:
node - the Node to serialize

comment

public void comment(String comment)
            throws SAXException
Receive notification of a comment.
Specified by:
comment in interface org.apache.xml.serializer.ExtendedLexicalHandler
Overrides:
comment in interface SerializerBase
See Also:
ExtendedLexicalHandler.comment(String)

error

public void error(SAXParseException exc)
            throws SAXException
Overrides:
error in interface SerializerBase
See Also:
org.xml.sax.ErrorHandler.error(SAXParseException)

fatalError

public void fatalError(SAXParseException exc)
            throws SAXException
Overrides:
fatalError in interface SerializerBase
See Also:
org.xml.sax.ErrorHandler.fatalError(SAXParseException)

flushPending

public void flushPending()
            throws SAXException
This method flushes any pending events, which can be startDocument() closing the opening tag of an element, or closing an open CDATA section.
Specified by:
flushPending in interface SerializationHandler

processingInstruction

public void processingInstruction(String target,
                                  String data)
            throws SAXException
Do nothing as this is an abstract class. All subclasses will need to define their behavior if it is different.
See Also:
org.xml.sax.ContentHandler.processingInstruction(String, String)

reset

public boolean reset()
Try's to reset the super class and reset this class for re-use, so that you don't need to create a new serializer (mostly for performance reasons).
Specified by:
reset in interface Serializer
Overrides:
reset in interface SerializerBase
Returns:
true if the class was successfuly reset.

setCdataSectionElements

public void setCdataSectionElements(Vector URI_and_localNames)
Does nothing. The setting of CDATA section elements has an impact on stream serializers.
Specified by:
setCdataSectionElements in interface org.apache.xml.serializer.XSLOutputAttributes
See Also:
SerializationHandler.setCdataSectionElements(java.util.Vector)

setContentHandler

public void setContentHandler(ContentHandler _saxHandler)
Sets the SAX ContentHandler.
Specified by:
setContentHandler in interface SerializationHandler
Parameters:
_saxHandler - The ContentHandler to set

setLexHandler

public void setLexHandler(LexicalHandler _lexHandler)
Sets the LexicalHandler.
Parameters:
_lexHandler - The LexicalHandler to set

setShouldOutputNSAttr

public void setShouldOutputNSAttr(boolean doOutputNSAttr)
Set whether or not namespace declarations (e.g. xmlns:foo) should appear as attributes of elements
Parameters:
doOutputNSAttr - whether or not namespace declarations should appear as attributes

setTransformState

public void setTransformState(TransformStateSetter ts)
Pass in a reference to a TransformState object, which can be used during SAX ContentHandler events to obtain information about he state of the transformation. This method will be called before each startDocument event.
Parameters:
ts - A reference to a TransformState object

startDTD

public void startDTD(String arg0,
                     String arg1,
                     String arg2)
            throws SAXException
Do nothing.
See Also:
org.xml.sax.ext.LexicalHandler.startDTD(String, String, String)

startElement

public void startElement(String qName)
            throws SAXException
An element starts, but attributes are not fully known yet.
Specified by:
startElement in interface org.apache.xml.serializer.ExtendedContentHandler
Parameters:
qName - the element name, with prefix (if any).
See Also:
ExtendedContentHandler.startElement(String)

startElement

public void startElement(String uri,
                         String localName,
                         String qName)
            throws SAXException
Receives notification that an element starts, but attributes are not fully known yet.
Specified by:
startElement in interface org.apache.xml.serializer.ExtendedContentHandler
Parameters:
uri - the URI of the namespace of the element (optional)
localName - the element name, but without prefix (optional)
qName - the element name, with prefix, if any (required)
See Also:
ExtendedContentHandler.startElement(String, String, String)

startElement

public void startElement(String arg0,
                         String arg1,
                         String arg2,
                         Attributes arg3)
            throws SAXException
Receive notification of the beginning of an element, although this is a SAX method additional namespace or attribute information can occur before or after this call, that is associated with this element.
See Also:
org.xml.sax.ContentHandler.startElement, org.xml.sax.ContentHandler.endElement, org.xml.sax.AttributeList, org.xml.sax.ContentHandler.startElement(String,String,String,Attributes)

warning

public void warning(SAXParseException exc)
            throws SAXException
Overrides:
warning in interface SerializerBase
See Also:
org.xml.sax.ErrorHandler.warning(SAXParseException)

Copyright B) 2005 Apache XML Project. All Rights Reserved.