|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xml.serializer.SerializerBase org.apache.xml.serializer.ToSAXHandler org.apache.xml.serializer.ToXMLSAXHandler
public final class ToXMLSAXHandler
This class receives notification of SAX-like events, and with gathered information over these calls it will invoke the equivalent SAX methods on a handler, the ultimate xsl:output method is known to be "xml". This class is not a public API.
Field Summary | |
---|---|
protected boolean |
m_escapeSetting
Keeps track of whether output escaping is currently enabled |
Fields inherited from class org.apache.xml.serializer.ToSAXHandler |
---|
m_lexHandler, m_saxHandler, m_state |
Fields inherited from class org.apache.xml.serializer.SerializerBase |
---|
m_attrBuff, m_attributes, m_CdataElems, m_cdataTagOpen, m_charsBuff, m_docIsEmpty, m_doctypePublic, m_doctypeSystem, m_doIndent, m_elemContext, m_indentAmount, m_inEntityRef, m_inExternalDTD, m_mediatype, m_needToCallStartDocument, m_needToOutputDocTypeDecl, m_prefixMap, m_shouldNotWriteXMLHeader, m_sourceLocator, m_standaloneWasSpecified, m_StringOfCDATASections, m_tracer, m_version, m_writer, PKG_NAME, PKG_PATH |
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, XML_PREFIX, XMLNS_PREFIX, XMLNS_URI, XMLVERSION10, XMLVERSION11 |
Constructor Summary | |
---|---|
ToXMLSAXHandler()
|
|
ToXMLSAXHandler(org.xml.sax.ContentHandler handler,
org.xml.sax.ext.LexicalHandler lex,
java.lang.String encoding)
|
|
ToXMLSAXHandler(org.xml.sax.ContentHandler handler,
java.lang.String encoding)
|
Method Summary | |
---|---|
void |
addAttribute(java.lang.String uri,
java.lang.String localName,
java.lang.String rawName,
java.lang.String type,
java.lang.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(java.lang.String arg0,
java.lang.String arg1,
java.lang.String arg2,
java.lang.String arg3,
java.lang.String arg4)
|
void |
characters(char[] ch,
int off,
int len)
|
void |
characters(java.lang.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(java.lang.String arg0,
java.lang.String arg1)
|
void |
endCDATA()
|
void |
endDocument()
Receives notification of the end of the document. |
void |
endDTD()
|
void |
endElement(java.lang.String elemName)
This method is used to notify that an element has ended. |
void |
endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName)
|
void |
endPrefixMapping(java.lang.String prefix)
|
private void |
ensurePrefixIsDeclared(java.lang.String ns,
java.lang.String rawName)
|
void |
externalEntityDecl(java.lang.String arg0,
java.lang.String arg1,
java.lang.String arg2)
|
java.util.Properties |
getOutputFormat()
Returns the output format properties for this serializer. |
java.io.OutputStream |
getOutputStream()
Get the output stream where the events will be serialized to. |
java.io.Writer |
getWriter()
Get the character stream where the events will be serialized to. |
void |
ignorableWhitespace(char[] arg0,
int arg1,
int arg2)
|
void |
indent(int n)
Do nothing for SAX. |
void |
internalEntityDecl(java.lang.String arg0,
java.lang.String arg1)
|
void |
namespaceAfterStartElement(java.lang.String prefix,
java.lang.String uri)
Send a namespace declaration in the output document. |
protected boolean |
popNamespace(java.lang.String prefix)
Undeclare the namespace that is currently pointed to by a given prefix. |
void |
processingInstruction(java.lang.String target,
java.lang.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). |
private void |
resetToXMLSAXHandler()
Reset all of the fields owned by ToXMLSAXHandler class |
void |
serialize(org.w3c.dom.Node node)
Serializes the DOM node. |
void |
setDocumentLocator(org.xml.sax.Locator arg0)
Receive an object for locating the origin of SAX document events. |
boolean |
setEscaping(boolean escape)
Turns special character escaping on/off. |
void |
setOutputFormat(java.util.Properties format)
Specifies an output format for this serializer. |
void |
setOutputStream(java.io.OutputStream output)
Specifies an output stream to which the document should be serialized. |
void |
setWriter(java.io.Writer writer)
Specifies a writer to which the document should be serialized. |
void |
skippedEntity(java.lang.String arg0)
|
void |
startCDATA()
|
void |
startElement(java.lang.String elementName)
An element starts, but attributes are not fully known yet. |
void |
startElement(java.lang.String elementNamespaceURI,
java.lang.String elementLocalName,
java.lang.String elementName)
Start an element in the output document. |
void |
startElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String name,
org.xml.sax.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(java.lang.String arg0)
|
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
|
boolean |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri,
boolean shouldFlush)
Remember the prefix/uri mapping at the current nested element depth. |
Methods inherited from class org.apache.xml.serializer.ToSAXHandler |
---|
addUniqueAttribute, characters, comment, error, fatalError, flushPending, getShouldOutputNSAttr, setCdataSectionElements, setContentHandler, setLexHandler, setShouldOutputNSAttr, setTransformState, startDocumentInternal, startDTD, warning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean m_escapeSetting
Constructor Detail |
---|
public ToXMLSAXHandler()
public ToXMLSAXHandler(org.xml.sax.ContentHandler handler, java.lang.String encoding)
public ToXMLSAXHandler(org.xml.sax.ContentHandler handler, org.xml.sax.ext.LexicalHandler lex, java.lang.String encoding)
Method Detail |
---|
public java.util.Properties getOutputFormat()
Serializer
Serializer.getOutputFormat()
public java.io.OutputStream getOutputStream()
Serializer
Serializer.getOutputStream()
public java.io.Writer getWriter()
Serializer
Serializer.getWriter()
public void indent(int n) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void serialize(org.w3c.dom.Node node) throws java.io.IOException
DOMSerializer
node
- the DOM node to serialize
java.io.IOException
- if an I/O exception occured while serializingDOMSerializer.serialize(Node)
public boolean setEscaping(boolean escape) throws org.xml.sax.SAXException
SerializationHandler
escape
- true if escaping is to be set on.
org.xml.sax.SAXException
SerializationHandler.setEscaping(boolean)
public void setOutputFormat(java.util.Properties format)
Serializer
The standard property keys supported are: "method", "version", "encoding", "omit-xml-declaration", "standalone", doctype-public", "doctype-system", "cdata-section-elements", "indent", "media-type". These property keys and their values are described in the XSLT recommendation, see XSLT 1.0 recommendation
The non-standard property keys supported are defined in OutputPropertiesFactory
.
This method can be called multiple times before a document is serialized. Each time it is called more, or over-riding property values, can be specified. One property value that can not be changed is that of the "method" property key.
The value of the "cdata-section-elements" property key is a whitespace separated list of elements. If the element is in a namespace then value is passed in this format: {uri}localName
If the "cdata-section-elements" key is specified on multiple calls to this method the set of elements specified in the value is not replaced from one call to the next, but it is cumulative across the calls.
format
- The output format to use, as a set of key/value pairs.Serializer.setOutputFormat(Properties)
public void setOutputStream(java.io.OutputStream output)
Serializer
The encoding specified in the output Properties
is used, or
if no encoding was specified, the default for the selected
output method.
Only one of setWriter() or setOutputStream() should be called.
output
- The output streamSerializer.setOutputStream(OutputStream)
public void setWriter(java.io.Writer writer)
Serializer
The encoding specified for the output Properties
must be
identical to the output format used with the writer.
Only one of setWriter() or setOutputStream() should be called.
writer
- The output writer streamSerializer.setWriter(Writer)
public void attributeDecl(java.lang.String arg0, java.lang.String arg1, java.lang.String arg2, java.lang.String arg3, java.lang.String arg4) throws org.xml.sax.SAXException
org.xml.sax.SAXException
DeclHandler.attributeDecl(String, String, String, String, String)
public void elementDecl(java.lang.String arg0, java.lang.String arg1) throws org.xml.sax.SAXException
org.xml.sax.SAXException
DeclHandler.elementDecl(String, String)
public void externalEntityDecl(java.lang.String arg0, java.lang.String arg1, java.lang.String arg2) throws org.xml.sax.SAXException
org.xml.sax.SAXException
DeclHandler.externalEntityDecl(String, String, String)
public void internalEntityDecl(java.lang.String arg0, java.lang.String arg1) throws org.xml.sax.SAXException
org.xml.sax.SAXException
DeclHandler.internalEntityDecl(String, String)
public void endDocument() throws org.xml.sax.SAXException
org.xml.sax.SAXException
ContentHandler.endDocument()
protected void closeStartTag() throws org.xml.sax.SAXException
closeStartTag
in class ToSAXHandler
org.xml.sax.SAXException
public void closeCDATA() throws org.xml.sax.SAXException
closeCDATA
in class ToSAXHandler
org.xml.sax.SAXException
public void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
org.xml.sax.SAXException
ContentHandler.endElement(String, String, String)
public void endPrefixMapping(java.lang.String prefix) throws org.xml.sax.SAXException
org.xml.sax.SAXException
ContentHandler.endPrefixMapping(String)
public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws org.xml.sax.SAXException
org.xml.sax.SAXException
ContentHandler.ignorableWhitespace(char[], int, int)
public void setDocumentLocator(org.xml.sax.Locator arg0)
SerializerBase
setDocumentLocator
in interface org.xml.sax.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(java.lang.String arg0) throws org.xml.sax.SAXException
org.xml.sax.SAXException
ContentHandler.skippedEntity(String)
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException
prefix
- The prefix that maps to the URIuri
- The URI for the namespace
org.xml.sax.SAXException
ContentHandler.startPrefixMapping(String, String)
public boolean startPrefixMapping(java.lang.String prefix, java.lang.String uri, boolean shouldFlush) throws org.xml.sax.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).
org.xml.sax.SAXException
ContentHandler.startPrefixMapping(String, String)
public void comment(char[] arg0, int arg1, int arg2) throws org.xml.sax.SAXException
org.xml.sax.SAXException
LexicalHandler.comment(char[], int, int)
public void endCDATA() throws org.xml.sax.SAXException
org.xml.sax.SAXException
LexicalHandler.endCDATA()
public void endDTD() throws org.xml.sax.SAXException
org.xml.sax.SAXException
LexicalHandler.endDTD()
public void startEntity(java.lang.String arg0) throws org.xml.sax.SAXException
org.xml.sax.SAXException
LexicalHandler.startEntity(String)
public void characters(java.lang.String chars) throws org.xml.sax.SAXException
ToSAXHandler
characters
in interface ExtendedContentHandler
characters
in class ToSAXHandler
chars
- The string of characters to process.
org.xml.sax.SAXException
ExtendedContentHandler.characters(String)
public void startElement(java.lang.String elementNamespaceURI, java.lang.String elementLocalName, java.lang.String elementName) throws org.xml.sax.SAXException
startElement
in interface 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)
org.xml.sax.SAXException
ExtendedContentHandler.startElement(String, String, String)
public void startElement(java.lang.String elementName) throws org.xml.sax.SAXException
ToSAXHandler
startElement
in interface ExtendedContentHandler
startElement
in class ToSAXHandler
elementName
- the element name, with prefix (if any).
org.xml.sax.SAXException
ExtendedContentHandler.startElement(String)
public void characters(char[] ch, int off, int len) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void endElement(java.lang.String elemName) throws org.xml.sax.SAXException
ExtendedContentHandler
endElement(namespaceURI,localName,qName)only the last parameter is passed. If needed the serializer can derive the localName from the qualified name and derive the namespaceURI from its implementation.
elemName
- the fully qualified element name.
org.xml.sax.SAXException
ExtendedContentHandler.endElement(String)
public void namespaceAfterStartElement(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException
namespaceAfterStartElement
in interface ExtendedContentHandler
namespaceAfterStartElement
in class SerializerBase
prefix
- the URI of the namespaceuri
- the prefix associated with the given URI.
org.xml.sax.SAXException
ExtendedContentHandler.namespaceAfterStartElement(String, String)
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
ToSAXHandler
processingInstruction
in interface org.xml.sax.ContentHandler
processingInstruction
in class ToSAXHandler
org.xml.sax.SAXException
Send a processing instruction to the output document
protected boolean popNamespace(java.lang.String prefix)
public void startCDATA() throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String name, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
ToSAXHandler
startElement
in interface org.xml.sax.ContentHandler
startElement
in class ToSAXHandler
org.xml.sax.SAXException
ContentHandler.startElement(String, String, String, Attributes)
private void ensurePrefixIsDeclared(java.lang.String ns, java.lang.String rawName) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void addAttribute(java.lang.String uri, java.lang.String localName, java.lang.String rawName, java.lang.String type, java.lang.String value, boolean XSLAttribute) throws org.xml.sax.SAXException
addAttribute
in interface 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 element
org.xml.sax.SAXException
ExtendedContentHandler.addAttribute(String, String, String, String, String)
public boolean reset()
reset
in interface Serializer
reset
in class ToSAXHandler
Serializer.reset()
private void resetToXMLSAXHandler()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |