org.apache.xml.serializer

Class ToTextSAXHandler

Implemented Interfaces:
org.xml.sax.ContentHandler, DeclHandler, org.xml.sax.DTDHandler, ErrorHandler, DOMSerializer, ExtendedContentHandler, ExtendedLexicalHandler, org.xml.sax.ext.LexicalHandler, SerializationHandler, Serializer, org.apache.xml.serializer.SerializerConstants, org.apache.xml.serializer.XSLOutputAttributes

public final class ToTextSAXHandler
extends ToSAXHandler

This class converts SAX-like event to SAX events for xsl:output method "text". This class is only to be used internally. This class is not a public API.

Field Summary

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

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

ToTextSAXHandler(ContentHandler hdlr, LexicalHandler lex, String encoding)
ToTextSAXHandler(ContentHandler handler, String encoding)
From XSLTC

Method Summary

void
addAttribute(String name, String value)
From XSLTC
void
addAttribute(String uri, String localName, String rawName, String type, String value, boolean XSLAttribute)
void
attributeDecl(String arg0, String arg1, String arg2, String arg3, String arg4)
void
characters(String characters)
void
characters(char[] characters, int offset, int length)
void
comment(String data)
Receive notification of a comment.
void
comment(ch[] , int start, int length)
void
elementDecl(String arg0, String arg1)
void
endCDATA()
void
endDTD()
void
endDocument()
From XSLTC
void
endElement(String elemName)
From XSLTC
void
endElement(String arg0, String arg1, String arg2)
void
endPrefixMapping(String arg0)
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)
Does nothing because the indent attribute is ignored for text output.
void
internalEntityDecl(String arg0, String arg1)
void
namespaceAfterStartElement(String prefix, String uri)
This method is used when a prefix/uri namespace mapping is indicated after the element was started with a startElement() and before and endElement().
void
processingInstruction(String arg0, String arg1)
From XSLTC
boolean
reset()
void
serialize(Node node)
void
setDocumentLocator(Locator arg0)
boolean
setEscaping(boolean escape)
void
setIndent(boolean indent)
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)
From XSLTC
void
startElement(String arg0, String arg1, String arg2, Attributes arg3)
void
startEntity(String arg0)
void
startPrefixMapping(String prefix, String uri)
boolean
startPrefixMapping(String prefix, String uri, boolean shouldFlush)
This method is used to notify that a prefix maping is to start, which can be for the current element, or for the one to come.

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, asDOM3Serializer, asDOMSerializer, characters, close, comment, documentIsEmpty, endEntity, entityReference, error, fatalError, fireEndEntity, getDoctypePublic, getDoctypeSystem, getEncoding, getIndent, getIndentAmount, getMediaType, getNamespaceMappings, getNamespaceURI, getNamespaceURIFromPrefix, getOmitXMLDeclaration, getOutputProperty, getOutputPropertyDefault, getOutputPropertyNonDefault, getPrefix, getStandalone, getTransformer, getVersion, namespaceAfterStartElement, notationDecl, reset, setDTDEntityExpansion, setDoctype, setDoctypePublic, setDoctypeSystem, setDocumentLocator, setEncoding, setIndent, setIndentAmount, setMediaType, setNamespaceMappings, setOmitXMLDeclaration, setOutputProperty, setOutputPropertyDefault, setSourceLocator, setStandalone, setTransformer, setVersion, startDocument, unparsedEntityDecl, warning

Constructor Details

ToTextSAXHandler

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

ToTextSAXHandler

public ToTextSAXHandler(ContentHandler handler,
                        String encoding)
From XSLTC

Method Details

addAttribute

public void addAttribute(String name,
                         String value)
From XSLTC
Specified by:
addAttribute in interface ExtendedContentHandler
Overrides:
addAttribute in interface SerializerBase

addAttribute

public void addAttribute(String uri,
                         String localName,
                         String rawName,
                         String type,
                         String value,
                         boolean XSLAttribute)
Specified by:
addAttribute in interface ExtendedContentHandler
Overrides:
addAttribute in interface SerializerBase

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 characters)
            throws SAXException
Specified by:
characters in interface ExtendedContentHandler
Overrides:
characters in interface ToSAXHandler

characters

public void characters(char[] characters,
                       int offset,
                       int length)
            throws SAXException
See Also:
org.xml.sax.ContentHandler.characters(char[], int, int)

comment

public void comment(String data)
            throws SAXException
Receive notification of a comment.
Specified by:
comment in interface ExtendedLexicalHandler
Overrides:
comment in interface ToSAXHandler

comment

public void comment(ch[] ,
                    int start,
                    int length)
            throws SAXException

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
From XSLTC
See Also:
org.xml.sax.ContentHandler.endDocument()

endElement

public void endElement(String elemName)
            throws SAXException
From XSLTC
Specified by:
endElement in interface ExtendedContentHandler

endElement

public void endElement(String arg0,
                       String arg1,
                       String arg2)
            throws SAXException
See Also:
org.xml.sax.ContentHandler.endElement(String, String, String)

endPrefixMapping

public void endPrefixMapping(String arg0)
            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
Does nothing because the indent attribute is ignored for text output.

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
This method is used when a prefix/uri namespace mapping is indicated after the element was started with a startElement() and before and endElement(). startPrefixMapping(prefix,uri) would be used before the startElement() call.
Specified by:
namespaceAfterStartElement in interface ExtendedContentHandler
Overrides:
namespaceAfterStartElement in interface SerializerBase
Parameters:
prefix - the prefix associated with the given URI.
uri - the URI of the namespace

processingInstruction

public void processingInstruction(String arg0,
                                  String arg1)
            throws SAXException
From XSLTC
Overrides:
processingInstruction in interface ToSAXHandler
See Also:
org.xml.sax.ContentHandler.processingInstruction(String, String)

reset

public boolean reset()
Specified by:
reset in interface Serializer
Overrides:
reset in interface ToSAXHandler

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)
Specified by:
setEscaping in interface SerializationHandler

setIndent

public void setIndent(boolean indent)
Specified by:
setIndent in interface org.apache.xml.serializer.XSLOutputAttributes
Overrides:
setIndent in interface SerializerBase
See Also:
SerializationHandler.setIndent(boolean)

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
See Also:
org.xml.sax.ext.LexicalHandler.startCDATA()

startElement

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

startElement

public void startElement(String elementNamespaceURI,
                         String elementLocalName,
                         String elementName)
            throws SAXException
From XSLTC
Specified by:
startElement in interface ExtendedContentHandler
Overrides:
startElement in interface ToSAXHandler

startElement

public void startElement(String arg0,
                         String arg1,
                         String arg2,
                         Attributes arg3)
            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

startPrefixMapping

public boolean startPrefixMapping(String prefix,
                                  String uri,
                                  boolean shouldFlush)
            throws SAXException
This method is used to notify that a prefix maping is to start, which can be for the current element, or for the one to come.
Specified by:
startPrefixMapping in interface ExtendedContentHandler
Parameters:
prefix - the prefix that maps to the given URI
uri - the namespace URI of the given prefix
shouldFlush - if true this call is like the SAX startPrefixMapping(prefix,uri) call and the mapping applies to the element to come. If false the mapping applies to the current element.
Returns:
boolean false if the prefix mapping was already in effect (in other words we are just re-declaring), true if this is a new, never before seen mapping for the element.

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