public final class ToXMLSAXHandler extends ToSAXHandler
Modifier and Type | Field and Description |
---|---|
static String |
CDATA_CONTINUE
To insert ]]> in a CDATA section by ending the last CDATA section with
]] and starting the next CDATA section with >
|
static String |
CDATA_DELIMITER_CLOSE
The constant "]]>"
|
static String |
CDATA_DELIMITER_OPEN |
static String |
DEFAULT_SAX_SERIALIZER |
static String |
EMPTYSTRING |
static String |
ENTITY_AMP |
static String |
ENTITY_CRLF |
static String |
ENTITY_GT |
static String |
ENTITY_LT |
static String |
ENTITY_QUOT |
protected static org.slf4j.Logger |
log |
protected boolean |
m_escapeSetting
Keeps track of whether output escaping is currently enabled
|
static String |
XML_PREFIX |
static String |
XMLNS_PREFIX |
static String |
XMLNS_URI |
static String |
XMLVERSION10 |
static String |
XMLVERSION11
Define the XML version.
|
m_lexHandler, m_saxHandler, m_state
m_attrBuff, m_attributes, m_CdataElems, m_cdataTagOpen, m_charsBuff, m_doctypePublic, m_doctypeSystem, m_doIndent, m_elemContext, m_indentAmount, m_inEntityRef, m_inExternalDTD, m_mediatype, m_needToCallStartDocument, m_prefixMap, m_shouldNotWriteXMLHeader, m_sourceLocator, m_standaloneWasSpecified, m_StringOfCDATASections, m_tracer, m_version, m_writer, PKG_NAME, PKG_PATH
Constructor and Description |
---|
ToXMLSAXHandler() |
ToXMLSAXHandler(ContentHandler handler,
LexicalHandler lex,
String encoding) |
ToXMLSAXHandler(ContentHandler handler,
String encoding) |
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(String uri,
String localName,
String rawName,
String type,
String value,
boolean XSLAttribute)
Adds the given attribute to the set of attributes, and also makes sure
that the needed prefix/uri mapping is declared, but only if there is a
currently open element.
|
void |
attributeDecl(String arg0,
String arg1,
String arg2,
String arg3,
String arg4) |
void |
characters(char[] ch,
int off,
int len) |
void |
characters(String chars)
Receive notification of character data.
|
void |
closeCDATA()
Closes ane open cdata tag, and
unlike the this.endCDATA() method (from the LexicalHandler) interface,
this "internal" method will send the endCDATA() call to the wrapped
handler.
|
protected void |
closeStartTag()
This method is called when all the data needed for a call to the
SAX handler's startElement() method has been gathered.
|
void |
comment(char[] arg0,
int arg1,
int arg2) |
void |
elementDecl(String arg0,
String arg1) |
void |
endCDATA() |
void |
endDocument()
Receives notification of the end of the document.
|
void |
endDTD() |
void |
endElement(String elemName) |
void |
endElement(String namespaceURI,
String localName,
String qName) |
void |
endPrefixMapping(String prefix) |
void |
externalEntityDecl(String arg0,
String arg1,
String arg2) |
Properties |
getOutputFormat() |
OutputStream |
getOutputStream() |
Writer |
getWriter() |
void |
ignorableWhitespace(char[] arg0,
int arg1,
int arg2) |
void |
indent(int n)
Do nothing for SAX.
|
void |
internalEntityDecl(String arg0,
String arg1) |
void |
namespaceAfterStartElement(String prefix,
String uri)
Send a namespace declaration in the output document.
|
protected boolean |
popNamespace(String prefix)
Undeclare the namespace that is currently pointed to by a given
prefix.
|
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 |
serialize(Node node) |
void |
setDocumentLocator(Locator arg0)
Receive an object for locating the origin of SAX document events.
|
boolean |
setEscaping(boolean escape) |
void |
setOutputFormat(Properties format) |
void |
setOutputStream(OutputStream output) |
void |
setWriter(Writer writer) |
void |
skippedEntity(String arg0) |
void |
startCDATA() |
void |
startElement(String elementName)
An element starts, but attributes are not fully known yet.
|
void |
startElement(String elementNamespaceURI,
String elementLocalName,
String elementName)
Start an element in the output document.
|
void |
startElement(String namespaceURI,
String localName,
String name,
Attributes atts)
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 |
startEntity(String arg0) |
void |
startPrefixMapping(String prefix,
String uri) |
boolean |
startPrefixMapping(String prefix,
String uri,
boolean shouldFlush)
Remember the prefix/uri mapping at the current nested element depth.
|
addUniqueAttribute, characters, comment, error, fatalError, flushPending, setCdataSectionElements, setContentHandler, setLexHandler, setShouldOutputNSAttr, setTransformState, startDocumentInternal, startDTD, warning
addAttribute, addAttribute, addAttributeAlways, addAttributes, addXSLAttribute, asContentHandler, asDOM3Serializer, asDOMSerializer, close, documentIsEmpty, endEntity, entityReference, fireCDATAEvent, fireCharEvent, fireCommentEvent, fireEndDoc, fireEndElem, fireEndEntity, fireEntityReference, fireEscapingEvent, fireStartDoc, fireStartElem, fireStartEntity, getDoctypePublic, getDoctypeSystem, getEncoding, getIndent, getIndentAmount, getLocalName, getMediaType, getNamespaceMappings, getNamespaceURI, getNamespaceURIFromPrefix, getOmitXMLDeclaration, getOutputProperty, getOutputPropertyDefault, getOutputPropertyNonDefault, getPrefix, getPrefixPart, getStandalone, getTransformer, getVersion, initCDATA, isCdataSection, notationDecl, patchName, setDoctype, setDoctypePublic, setDoctypeSystem, setDTDEntityExpansion, setEncoding, setIndent, setIndentAmount, setMediaType, setNamespaceMappings, setOmitXMLDeclaration, setOutputProperty, setOutputPropertyDefault, setSourceLocator, setStandalone, setStandaloneInternal, setTransformer, setVersion, startDocument, unparsedEntityDecl
protected static org.slf4j.Logger log
protected boolean m_escapeSetting
public static final String CDATA_CONTINUE
public static final String CDATA_DELIMITER_CLOSE
public static final String CDATA_DELIMITER_OPEN
public static final String EMPTYSTRING
public static final String ENTITY_AMP
public static final String ENTITY_CRLF
public static final String ENTITY_GT
public static final String ENTITY_LT
public static final String ENTITY_QUOT
public static final String XML_PREFIX
public static final String XMLNS_PREFIX
public static final String XMLNS_URI
public static final String DEFAULT_SAX_SERIALIZER
public static final String XMLVERSION11
public static final String XMLVERSION10
public ToXMLSAXHandler()
public ToXMLSAXHandler(ContentHandler handler, String encoding)
public ToXMLSAXHandler(ContentHandler handler, LexicalHandler lex, String encoding)
public Properties getOutputFormat()
Serializer#getOutputFormat()
public OutputStream getOutputStream()
Serializer#getOutputStream()
public Writer getWriter()
Serializer#getWriter()
public void indent(int n) throws SAXException
SAXException
public void serialize(Node node) throws IOException
IOException
DOMSerializer#serialize(Node)
public boolean setEscaping(boolean escape) throws SAXException
SAXException
SerializationHandler#setEscaping(boolean)
public void setOutputFormat(Properties format)
Serializer#setOutputFormat(Properties)
public void setOutputStream(OutputStream output)
Serializer#setOutputStream(OutputStream)
public void setWriter(Writer writer)
Serializer#setWriter(Writer)
public void attributeDecl(String arg0, String arg1, String arg2, String arg3, String arg4) throws SAXException
public void elementDecl(String arg0, String arg1) throws SAXException
SAXException
DeclHandler.elementDecl(String, String)
public void externalEntityDecl(String arg0, String arg1, String arg2) throws SAXException
SAXException
DeclHandler.externalEntityDecl(String, String, String)
public void internalEntityDecl(String arg0, String arg1) throws SAXException
SAXException
DeclHandler.internalEntityDecl(String, String)
public void endDocument() throws SAXException
SAXException
ContentHandler.endDocument()
protected void closeStartTag() throws SAXException
closeStartTag
in class ToSAXHandler
SAXException
public void closeCDATA() throws SAXException
closeCDATA
in class ToSAXHandler
SAXException
public void endElement(String namespaceURI, String localName, String qName) throws SAXException
SAXException
ContentHandler.endElement(String, String, String)
public void endPrefixMapping(String prefix) throws SAXException
SAXException
ContentHandler.endPrefixMapping(String)
public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws SAXException
SAXException
ContentHandler.ignorableWhitespace(char[], int, int)
public void setDocumentLocator(Locator arg0)
SerializerBase
setDocumentLocator
in interface ContentHandler
setDocumentLocator
in class SerializerBase
arg0
- An object that can return the location of any SAX document
event.
Receive an object for locating the origin of SAX document events.
SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface.
The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application's business rules). The information returned by the locator is probably not sufficient for use with a search engine.
Note that the locator will return correct information only during the invocation of the events in this interface. The application should not attempt to use it at any other time.
ContentHandler.setDocumentLocator(Locator)
public void skippedEntity(String arg0) throws SAXException
SAXException
ContentHandler.skippedEntity(String)
public void startPrefixMapping(String prefix, String uri) throws SAXException
prefix
- The prefix that maps to the URIuri
- The URI for the namespaceSAXException
ContentHandler.startPrefixMapping(String, String)
public boolean startPrefixMapping(String prefix, String uri, boolean shouldFlush) throws SAXException
prefix
- The prefix that maps to the URIuri
- The URI for the namespaceshouldFlush
- a flag indicating if the mapping applies to the
current element or an up coming child (not used).SAXException
ContentHandler.startPrefixMapping(String, String)
public void comment(char[] arg0, int arg1, int arg2) throws SAXException
SAXException
LexicalHandler.comment(char[], int, int)
public void endCDATA() throws SAXException
SAXException
LexicalHandler.endCDATA()
public void endDTD() throws SAXException
SAXException
LexicalHandler.endDTD()
public void startEntity(String arg0) throws SAXException
SAXException
LexicalHandler.startEntity(String)
public void characters(String chars) throws SAXException
ToSAXHandler
characters
in interface org.apache.xml.serializer.ExtendedContentHandler
characters
in class ToSAXHandler
chars
- The string of characters to process.SAXException
ExtendedContentHandler#characters(String)
public void startElement(String elementNamespaceURI, String elementLocalName, String elementName) throws SAXException
startElement
in interface org.apache.xml.serializer.ExtendedContentHandler
startElement
in class ToSAXHandler
elementNamespaceURI
- the URI of the namespace of the element (optional)elementLocalName
- the element name, but without prefix (optional)elementName
- the element name, with prefix, if any (required)SAXException
ExtendedContentHandler#startElement(String, String, String)
public void startElement(String elementName) throws SAXException
ToSAXHandler
startElement
in interface org.apache.xml.serializer.ExtendedContentHandler
startElement
in class ToSAXHandler
elementName
- the element name, with prefix (if any).SAXException
ExtendedContentHandler#startElement(String)
public void characters(char[] ch, int off, int len) throws SAXException
SAXException
public void endElement(String elemName) throws SAXException
SAXException
ExtendedContentHandler#endElement(String)
public void namespaceAfterStartElement(String prefix, String uri) throws SAXException
namespaceAfterStartElement
in interface org.apache.xml.serializer.ExtendedContentHandler
namespaceAfterStartElement
in class SerializerBase
prefix
- the URI of the namespaceuri
- the prefix associated with the given URI.SAXException
ExtendedContentHandler#namespaceAfterStartElement(String, String)
public void processingInstruction(String target, String data) throws SAXException
ToSAXHandler
processingInstruction
in interface ContentHandler
processingInstruction
in class ToSAXHandler
SAXException
Send a processing instruction to the output document
protected boolean popNamespace(String prefix)
public void startCDATA() throws SAXException
SAXException
public void startElement(String namespaceURI, String localName, String name, Attributes atts) throws SAXException
ToSAXHandler
startElement
in interface ContentHandler
startElement
in class ToSAXHandler
SAXException
ContentHandler.startElement(String, String, String, Attributes)
public void addAttribute(String uri, String localName, String rawName, String type, String value, boolean XSLAttribute) throws SAXException
addAttribute
in interface org.apache.xml.serializer.ExtendedContentHandler
addAttribute
in class SerializerBase
uri
- the URI of the attributelocalName
- the local name of the attributerawName
- the qualified name of the attributetype
- the type of the attribute (probably CDATA)value
- the value of the attributeXSLAttribute
- true if this attribute is coming from an xsl:attribute elementSAXException
ExtendedContentHandler#addAttribute(String, String, String, String, String)
public boolean reset()
reset
in interface org.apache.xml.serializer.Serializer
reset
in class ToSAXHandler
Serializer#reset()
Copyright © 2007-2019. All Rights Reserved.