org.apache.xml.serializer

Class ToTextSAXHandler

Implemented Interfaces:
ContentHandler, DeclHandler, DOM2DTM.CharacterNodeHandler, DOMSerializer, ErrorHandler, ExtendedContentHandler, ExtendedLexicalHandler, LexicalHandler, SerializationHandler, Serializer, SerializerConstants, XSLOutputAttributes

public class ToTextSAXHandler
extends ToSAXHandler

Authors:
minchau To change this generated comment edit the template variable "typecomment": Window>Preferences>Java>Templates. To enable and disable the creation of type comments go to Window>Preferences>Java>Code Generation.
Santiago Pericas-Geertsen

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

BEGCDATA, CDATA_CONTINUE, CDATA_DELIMITER_CLOSE, CDATA_DELIMITER_OPEN, CNTCDATA, DEFAULT_SAX_SERIALIZER, EMPTYSTRING, ENDCDATA, ENTITY_AMP, ENTITY_CRLF, ENTITY_GT, ENTITY_LT, ENTITY_QUOT, XMLNS_PREFIX, XMLNS_URI, XML_PREFIX

Constructor Summary

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

Method Summary

void
addAttribute(String name, String value)
From XSLTC
void
addAttribute(String uri, String localName, String rawName, String type, String value)
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)
Report an XML comment anywhere in the document.
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 to notify that a prefix mapping is to start, but after an element is started.
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)
Begin the scope of a prefix-URI Namespace mapping.
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, addAttributeAlways, addAttributes, 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, reset, setDoctype, setDoctypePublic, setDoctypeSystem, setDocumentLocator, setEncoding, setIndent, setIndentAmount, setMediaType, setNamespaceMappings, setOmitXMLDeclaration, setSourceLocator, setStandalone, setTransformer, setVersion, startDocument, warning

Constructor Details

ToTextSAXHandler

public ToTextSAXHandler(ContentHandler handler,
                        String encoding)
From XSLTC

ToTextSAXHandler

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

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)
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
Specified by:
attributeDecl in interface DeclHandler

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
Report an XML comment anywhere in the document.

This callback will be used for comments inside or outside the document element, including comments in the external DTD subset (if read). Comments in the DTD must be properly nested inside start/endDTD and start/endEntity events (if used).

Specified by:
comment in interface LexicalHandler
Parameters:
start - The starting position in the array.
length - The number of characters to use from the array.
Throws:
SAXException - The application may raise an exception.

elementDecl

public void elementDecl(String arg0,
                        String arg1)
            throws SAXException
Specified by:
elementDecl in interface DeclHandler

endCDATA

public void endCDATA()
            throws SAXException
Specified by:
endCDATA in interface LexicalHandler

endDTD

public void endDTD()
            throws SAXException
Specified by:
endDTD in interface LexicalHandler

endDocument

public void endDocument()
            throws SAXException
From XSLTC
Specified by:
endDocument in interface ContentHandler

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
Specified by:
endElement in interface ContentHandler

endPrefixMapping

public void endPrefixMapping(String arg0)
            throws SAXException
Specified by:
endPrefixMapping in interface ContentHandler

externalEntityDecl

public void externalEntityDecl(String arg0,
                               String arg1,
                               String arg2)
            throws SAXException
Specified by:
externalEntityDecl in interface DeclHandler

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
Specified by:
internalEntityDecl in interface DeclHandler

namespaceAfterStartElement

public void namespaceAfterStartElement(String prefix,
                                       String uri)
            throws SAXException
This method is used to notify that a prefix mapping is to start, but after an element is started. The SAX method call
 startPrefixMapping(prefix,uri)
 
is used just before an element starts and applies to the element to come, not to the current element. This method applies to the current element. For example one could make the calls in this order:
 startElement("prfx8:elem9")
 namespaceAfterStartElement("http://namespace8","prfx8")
 
Specified by:
namespaceAfterStartElement in interface ExtendedContentHandler
Overrides:
namespaceAfterStartElement in interface SerializerBase
Parameters:
prefix - the prefix that maps to the given namespace
uri - the namespace URI being declared
Throws:
SAXException -

processingInstruction

public void processingInstruction(String arg0,
                                  String arg1)
            throws SAXException
From XSLTC
Specified by:
processingInstruction in interface ContentHandler
Overrides:
processingInstruction in interface ToSAXHandler

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)
Specified by:
setDocumentLocator in interface ContentHandler
Overrides:
setDocumentLocator in interface SerializerBase

setEscaping

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

setIndent

public void setIndent(boolean indent)
Specified by:
setIndent in interface XSLOutputAttributes
Overrides:
setIndent in interface SerializerBase
See Also:
org.apache.xml.serializer.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
Specified by:
skippedEntity in interface ContentHandler

startCDATA

public void startCDATA()
            throws SAXException
Specified by:
startCDATA in interface LexicalHandler

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:
elementName - the element name, with prefix (if any).

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
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in interface ToSAXHandler

startEntity

public void startEntity(String arg0)
            throws SAXException
Specified by:
startEntity in interface LexicalHandler

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
            throws SAXException
Begin the scope of a prefix-URI Namespace mapping.

The information from this event is not necessary for normal Namespace processing: the SAX XML reader will automatically replace prefixes for element and attribute names when the http://xml.org/sax/features/namespaces feature is true (the default).

There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be expanded automatically; the start/endPrefixMapping event supplies the information to the application to expand prefixes in those contexts itself, if necessary.

Note that start/endPrefixMapping events are not guaranteed to be properly nested relative to each other: all startPrefixMapping events will occur immediately before the corresponding startElement event, and all endPrefixMapping events will occur immediately after the corresponding endElement event, but their order is not otherwise guaranteed.

There should never be start/endPrefixMapping events for the "xml" prefix, since it is predeclared and immutable.

Specified by:
startPrefixMapping in interface ContentHandler
Parameters:
prefix - The Namespace prefix being declared. An empty string is used for the default element namespace, which has no prefix.
uri - The Namespace URI the prefix is mapped to.
Throws:
SAXException - The client may throw an exception during processing.

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.
Throws:
SAXException -

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