org.apache.xml.serializer

Class ToXMLSAXHandler

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

public final class ToXMLSAXHandler
extends ToSAXHandler

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, it is only public because it is used by Xalan.

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

ToXMLSAXHandler()
ToXMLSAXHandler(ContentHandler handler, LexicalHandler lex, String encoding)
ToXMLSAXHandler(ContentHandler handler, String encoding)

Method Summary

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(String chars)
void
characters(char[] ch, int off, int len)
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.
void
comment(char[] arg0, int arg1, int arg2)
void
elementDecl(String arg0, String arg1)
void
endCDATA()
void
endDTD()
void
endDocument()
Receives notification of the end of the document.
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.
void
processingInstruction(String target, String data)
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)
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)
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.

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

addUniqueAttribute, characters, characters, comment, error, fatalError, flushPending, processingInstruction, reset, setCdataSectionElements, setContentHandler, setLexHandler, setShouldOutputNSAttr, setTransformState, startDTD, startElement, startElement, startElement, warning

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

ToXMLSAXHandler

public ToXMLSAXHandler()

ToXMLSAXHandler

public ToXMLSAXHandler(ContentHandler handler,
                       LexicalHandler lex,
                       String encoding)

ToXMLSAXHandler

public ToXMLSAXHandler(ContentHandler handler,
                       String encoding)

Method Details

addAttribute

public void addAttribute(String uri,
                         String localName,
                         String rawName,
                         String type,
                         String value,
                         boolean XSLAttribute)
            throws SAXException
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.
Specified by:
addAttribute in interface org.apache.xml.serializer.ExtendedContentHandler
Overrides:
addAttribute in interface SerializerBase
Parameters:
uri - the URI of the attribute
localName - the local name of the attribute
rawName - the qualified name of the attribute
type - the type of the attribute (probably CDATA)
value - the value of the attribute
XSLAttribute - true if this attribute is coming from an xsl:attribute element
See Also:
ExtendedContentHandler.addAttribute(String, String, String, String, String)

attributeDecl

public void attributeDecl(String arg0,
                          String arg1,
                          String arg2,
                          String arg3,
                          String arg4)
            throws SAXException
See Also:
org.xml.sax.ext.DeclHandler.attributeDecl(String, String, String, String, String)

characters

public void characters(String chars)
            throws SAXException
Specified by:
characters in interface org.apache.xml.serializer.ExtendedContentHandler
Overrides:
characters in interface ToSAXHandler
See Also:
ExtendedContentHandler.characters(String)

characters

public void characters(char[] ch,
                       int off,
                       int len)
            throws SAXException

closeCDATA

public void closeCDATA()
            throws SAXException
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.

comment

public void comment(char[] arg0,
                    int arg1,
                    int arg2)
            throws SAXException
See Also:
org.xml.sax.ext.LexicalHandler.comment(char[], int, int)

elementDecl

public void elementDecl(String arg0,
                        String arg1)
            throws SAXException
See Also:
org.xml.sax.ext.DeclHandler.elementDecl(String, String)

endCDATA

public void endCDATA()
            throws SAXException
See Also:
org.xml.sax.ext.LexicalHandler.endCDATA()

endDTD

public void endDTD()
            throws SAXException
See Also:
org.xml.sax.ext.LexicalHandler.endDTD()

endDocument

public void endDocument()
            throws SAXException
Receives notification of the end of the document.
See Also:
org.xml.sax.ContentHandler.endDocument()

endElement

public void endElement(String elemName)
            throws SAXException
Specified by:
endElement in interface org.apache.xml.serializer.ExtendedContentHandler
See Also:
ExtendedContentHandler.endElement(String)

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
            throws SAXException
See Also:
org.xml.sax.ContentHandler.endElement(String, String, String)

endPrefixMapping

public void endPrefixMapping(String prefix)
            throws SAXException
See Also:
org.xml.sax.ContentHandler.endPrefixMapping(String)

externalEntityDecl

public void externalEntityDecl(String arg0,
                               String arg1,
                               String arg2)
            throws SAXException
See Also:
org.xml.sax.ext.DeclHandler.externalEntityDecl(String, String, String)

getOutputFormat

public Properties getOutputFormat()
Specified by:
getOutputFormat in interface Serializer

getOutputStream

public OutputStream getOutputStream()
Specified by:
getOutputStream in interface Serializer

getWriter

public Writer getWriter()
Specified by:
getWriter in interface Serializer

ignorableWhitespace

public void ignorableWhitespace(char[] arg0,
                                int arg1,
                                int arg2)
            throws SAXException
See Also:
org.xml.sax.ContentHandler.ignorableWhitespace(char[], int, int)

indent

public void indent(int n)
            throws SAXException
Do nothing for SAX.

internalEntityDecl

public void internalEntityDecl(String arg0,
                               String arg1)
            throws SAXException
See Also:
org.xml.sax.ext.DeclHandler.internalEntityDecl(String, String)

namespaceAfterStartElement

public void namespaceAfterStartElement(String prefix,
                                       String uri)
            throws SAXException
Send a namespace declaration in the output document. The namespace declaration will not be include if the namespace is already in scope with the same prefix.
Specified by:
namespaceAfterStartElement in interface org.apache.xml.serializer.ExtendedContentHandler
Overrides:
namespaceAfterStartElement in interface SerializerBase

processingInstruction

public void processingInstruction(String target,
                                  String data)
            throws SAXException
Overrides:
processingInstruction in interface ToSAXHandler
See Also:
Send a processing instruction to the output document

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 ToSAXHandler
Returns:
true if the class was successfuly reset.

serialize

public void serialize(Node node)
            throws IOException
Specified by:
serialize in interface SerializationHandler
serialize in interface DOMSerializer

setDocumentLocator

public void setDocumentLocator(Locator arg0)
Overrides:
setDocumentLocator in interface SerializerBase
See Also:
org.xml.sax.ContentHandler.setDocumentLocator(Locator)

setEscaping

public boolean setEscaping(boolean escape)
            throws SAXException
Specified by:
setEscaping in interface SerializationHandler

setOutputFormat

public void setOutputFormat(Properties format)
Specified by:
setOutputFormat in interface Serializer

setOutputStream

public void setOutputStream(OutputStream output)
Specified by:
setOutputStream in interface Serializer

setWriter

public void setWriter(Writer writer)
Specified by:
setWriter in interface Serializer

skippedEntity

public void skippedEntity(String arg0)
            throws SAXException
See Also:
org.xml.sax.ContentHandler.skippedEntity(String)

startCDATA

public void startCDATA()
            throws SAXException

startElement

public void startElement(String elementName)
            throws SAXException
An element starts, but attributes are not fully known yet.
Specified by:
startElement in interface org.apache.xml.serializer.ExtendedContentHandler
Overrides:
startElement in interface ToSAXHandler
Parameters:
See Also:
ExtendedContentHandler.startElement(String)

startElement

public void startElement(String elementNamespaceURI,
                         String elementLocalName,
                         String elementName)
            throws SAXException
Start an element in the output document. This might be an XML element (data type) or a CDATA section.
Specified by:
startElement in interface org.apache.xml.serializer.ExtendedContentHandler
Overrides:
startElement in interface ToSAXHandler

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String name,
                         Attributes atts)
            throws SAXException
Overrides:
startElement in interface ToSAXHandler
See Also:
org.xml.sax.ContentHandler.startElement(String, String, String, Attributes)

startEntity

public void startEntity(String arg0)
            throws SAXException
See Also:
org.xml.sax.ext.LexicalHandler.startEntity(String)

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
            throws SAXException
Parameters:
prefix - The prefix that maps to the URI
uri - The URI for the namespace
See Also:
org.xml.sax.ContentHandler.startPrefixMapping(String, String)

startPrefixMapping

public boolean startPrefixMapping(String prefix,
                                  String uri,
                                  boolean shouldFlush)
            throws SAXException
Remember the prefix/uri mapping at the current nested element depth.
Specified by:
startPrefixMapping in interface org.apache.xml.serializer.ExtendedContentHandler
Parameters:
prefix - The prefix that maps to the URI
uri - The URI for the namespace
shouldFlush - a flag indicating if the mapping applies to the current element or an up coming child (not used).
See Also:
org.xml.sax.ContentHandler.startPrefixMapping(String, String)

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