Package org.apache.xml.serializer
Class ToSAXHandler
java.lang.Object
org.apache.xml.serializer.SerializerBase
org.apache.xml.serializer.ToSAXHandler
- All Implemented Interfaces:
DOMSerializer
,ExtendedContentHandler
,ExtendedLexicalHandler
,SerializationHandler
,Serializer
,ContentHandler
,DTDHandler
,ErrorHandler
,DeclHandler
,LexicalHandler
- Direct Known Subclasses:
ToHTMLSAXHandler
,ToTextSAXHandler
,ToXMLSAXHandler
This class is used to provide a base behavior to be inherited
by other To...SAXHandler serializers.
This class is not a public API.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
To insert ]]> in a CDATA section by ending the last CDATA section with ]] and starting the next CDATA section with >static final String
The constant "]]>"static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Define the XML version.Fields inherited from class org.apache.xml.serializer.SerializerBase
PKG_NAME, PKG_PATH
Fields inherited from interface org.apache.xml.serializer.ExtendedContentHandler
HTML_ATTREMPTY, HTML_ATTRURL, NO_BAD_CHARS
-
Constructor Summary
ConstructorsConstructorDescriptionToSAXHandler
(ContentHandler handler, String encoding) ToSAXHandler
(ContentHandler hdlr, LexicalHandler lex, String encoding) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addUniqueAttribute
(String qName, String value, int flags) Add a unique attributevoid
characters
(String characters) Receive notification of character data.void
characters
(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
Receive notification of a comment.void
error
(SAXParseException exc) void
void
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
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
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, asDOM3Serializer, asDOMSerializer, close, documentIsEmpty, endEntity, entityReference, fireEndEntity, getDoctypePublic, getDoctypeSystem, getEncoding, getIndent, getIndentAmount, getMediaType, getNamespaceMappings, getNamespaceURI, getNamespaceURIFromPrefix, getOmitXMLDeclaration, getOutputProperty, getOutputPropertyDefault, getOutputPropertyNonDefault, getPrefix, getStandalone, getTransformer, getVersion, namespaceAfterStartElement, notationDecl, setDoctype, setDoctypePublic, setDoctypeSystem, setDocumentLocator, setDTDEntityExpansion, setEncoding, setIndent, setIndentAmount, setMediaType, setNamespaceMappings, setOmitXMLDeclaration, setOutputProperty, setOutputPropertyDefault, setSourceLocator, setStandalone, setTransformer, setVersion, startDocument, unparsedEntityDecl
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
characters, declaration, endDocument, endElement, endPrefixMapping, ignorableWhitespace, skippedEntity, startPrefixMapping
Methods inherited from interface org.xml.sax.ext.DeclHandler
attributeDecl, elementDecl, externalEntityDecl, internalEntityDecl
Methods inherited from interface org.apache.xml.serializer.ExtendedContentHandler
endElement, startPrefixMapping
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, startCDATA, startEntity
Methods inherited from interface org.apache.xml.serializer.SerializationHandler
serialize, setEscaping
Methods inherited from interface org.apache.xml.serializer.Serializer
getOutputFormat, getOutputStream, getWriter, setOutputFormat, setOutputStream, setWriter
-
Field Details
-
CDATA_CONTINUE
To insert ]]> in a CDATA section by ending the last CDATA section with ]] and starting the next CDATA section with >- See Also:
-
CDATA_DELIMITER_CLOSE
The constant "]]>"- See Also:
-
CDATA_DELIMITER_OPEN
- See Also:
-
EMPTYSTRING
- See Also:
-
ENTITY_AMP
- See Also:
-
ENTITY_CRLF
- See Also:
-
ENTITY_GT
- See Also:
-
ENTITY_LT
- See Also:
-
ENTITY_QUOT
- See Also:
-
XML_PREFIX
- See Also:
-
XMLNS_PREFIX
- See Also:
-
XMLNS_URI
- See Also:
-
DEFAULT_SAX_SERIALIZER
-
XMLVERSION11
Define the XML version.- See Also:
-
XMLVERSION10
- See Also:
-
-
Constructor Details
-
ToSAXHandler
public ToSAXHandler() -
ToSAXHandler
-
ToSAXHandler
-
-
Method Details
-
startDTD
Do nothing.- Throws:
SAXException
- See Also:
-
characters
Receive notification of character data.- Parameters:
characters
- The string of characters to process.- Throws:
SAXException
- See Also:
-
comment
Receive notification of a comment.- Specified by:
comment
in interfaceExtendedLexicalHandler
- Overrides:
comment
in classSerializerBase
- Parameters:
comment
- the comment, but unlike the SAX comment() method this method takes a String rather than a character array.- Throws:
SAXException
- See Also:
-
processingInstruction
Do nothing as this is an abstract class. All subclasses will need to define their behavior if it is different.- Throws:
SAXException
- See Also:
-
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.- Throws:
SAXException
- Any SAX exception, possibly wrapping another exception.SAXException
- See Also:
-
setLexHandler
Sets the LexicalHandler.- Parameters:
_lexHandler
- The LexicalHandler to set
-
setContentHandler
Sets the SAX ContentHandler.- Parameters:
_saxHandler
- The ContentHandler to set- See Also:
-
setCdataSectionElements
Does nothing. The setting of CDATA section elements has an impact on stream serializers.- See Also:
-
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
-
flushPending
This method flushes any pending events, which can be startDocument() closing the opening tag of an element, or closing an open CDATA section.- Throws:
SAXException
-
setTransformState
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
-
startElement
Receives notification that an element starts, but attributes are not fully known yet.- 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)- Throws:
SAXException
- See Also:
-
startElement
An element starts, but attributes are not fully known yet.- Parameters:
qName
- the element name, with prefix (if any).- Throws:
SAXException
- See Also:
-
characters
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 interfaceExtendedContentHandler
- Overrides:
characters
in classSerializerBase
- Parameters:
node
- the Node to serialize- Throws:
SAXException
-
fatalError
- Specified by:
fatalError
in interfaceErrorHandler
- Overrides:
fatalError
in classSerializerBase
- Throws:
SAXException
- See Also:
-
error
- Specified by:
error
in interfaceErrorHandler
- Overrides:
error
in classSerializerBase
- Throws:
SAXException
- See Also:
-
warning
- Specified by:
warning
in interfaceErrorHandler
- Overrides:
warning
in classSerializerBase
- Throws:
SAXException
- See Also:
-
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 interfaceSerializer
- Overrides:
reset
in classSerializerBase
- Returns:
- true if the class was successfuly reset.
- See Also:
-
addUniqueAttribute
Add a unique attribute- Parameters:
qName
- the fully qualified attribute name.value
- the attribute valueflags
- a bitwise flag- Throws:
SAXException
-