org.apache.xml.serializer
Class EmptySerializer

java.lang.Object
  extended byorg.apache.xml.serializer.EmptySerializer
All Implemented Interfaces:
ContentHandler, DeclHandler, DOMSerializer, ErrorHandler, ExtendedContentHandler, ExtendedLexicalHandler, LexicalHandler, SerializationHandler, Serializer, XSLOutputAttributes
Direct Known Subclasses:
SimpleResultTreeImpl, StringValueHandler

public class EmptySerializer
extends Object
implements SerializationHandler

This class is an adapter class. Its only purpose is to be extended and for that extended class to over-ride all methods that are to be used.


Field Summary
 
Fields inherited from interface org.apache.xml.serializer.ExtendedContentHandler
HTML_ATTREMPTY, HTML_ATTRURL, NO_BAD_CHARS
 
Constructor Summary
EmptySerializer()
           
 
Method Summary
 void addAttribute(String name, String value)
          Add an attribute to the current element.
 void addAttribute(String uri, String localName, String rawName, String type, String value)
          Add at attribute to the current element
 void addAttributes(Attributes atts)
          Add attributes to the current element
 void addUniqueAttribute(String name, String value, int flags)
          Add a unique attribute to the current element.
 ContentHandler asContentHandler()
          Return a ContentHandler interface into this serializer.
 DOMSerializer asDOMSerializer()
          Return a DOMSerializer interface into this serializer.
 void attributeDecl(String arg0, String arg1, String arg2, String arg3, String arg4)
          Report an attribute type declaration.
 void characters(char[] arg0, int arg1, int arg2)
          Receive notification of character data.
 void characters(String chars)
          This method is used to notify of a character event, but passing the data as a character String rather than the standard character array.
 void close()
           
 void comment(char[] arg0, int arg1, int arg2)
          Report an XML comment anywhere in the document.
 void comment(String comment)
          This method is used to notify of a comment
 void elementDecl(String arg0, String arg1)
          Report an element type declaration.
 void endCDATA()
          Report the end of a CDATA section.
 void endDocument()
          Receive notification of the end of a document.
 void endDTD()
          Report the end of DTD declarations.
 void endElement(String elemName)
          This method is used to notify that an element has ended.
 void endElement(String arg0, String arg1, String arg2)
          Receive notification of the end of an element.
 void endEntity(String arg0)
          Report the end of an entity.
 void endPrefixMapping(String arg0)
          End the scope of a prefix-URI mapping.
 void entityReference(String entityName)
          Notify of an entity reference.
 void error(SAXParseException arg0)
          Receive notification of a recoverable error.
 void externalEntityDecl(String arg0, String arg1, String arg2)
          Report a parsed external entity declaration.
 void fatalError(SAXParseException arg0)
          Receive notification of a non-recoverable error.
 void flushPending()
          Flush any pending events currently queued up in the serializer.
 String getDoctypePublic()
          Returns the previously set value of the value to be used as the public identifier in the document type declaration (DTD).
 String getDoctypeSystem()
          Returns the previously set value of the value to be used as the system identifier in the document type declaration (DTD).
 String getEncoding()
           
 boolean getIndent()
           
 int getIndentAmount()
           
 String getMediaType()
           
 NamespaceMappings getNamespaceMappings()
          This method returns an object that has the current namespace mappings in effect.
 String getNamespaceURI(String name, boolean isElement)
          This method gets the prefix associated with a current element or attribute name.
 String getNamespaceURIFromPrefix(String prefix)
          This method returns the namespace URI currently associated with the prefix.
 boolean getOmitXMLDeclaration()
           
 Properties getOutputFormat()
          Returns the output format properties for this serializer.
 OutputStream getOutputStream()
          Get the output stream where the events will be serialized to.
 String getPrefix(String uri)
          This method returns the prefix that currently maps to the given namespace URI.
 String getStandalone()
           
 Transformer getTransformer()
          Get the transformer associated with the serializer.
 String getVersion()
           
 Writer getWriter()
          Get the character stream where the events will be serialized to.
 void ignorableWhitespace(char[] arg0, int arg1, int arg2)
          Receive notification of ignorable whitespace in element content.
 void internalEntityDecl(String arg0, String arg1)
          Report an internal entity declaration.
 void namespaceAfterStartElement(String uri, String prefix)
          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)
          Receive notification of a processing instruction.
 boolean reset()
          Resets the serializer.
 void serialize(Node node)
          Notify that the serializer should take this DOM node as input to be serialized.
 void setCdataSectionElements(Hashtable h)
           
 void setCdataSectionElements(Vector URI_and_localNames)
          Sets the value coming from the xsl:output cdata-section-elements stylesheet property.
 void setContentHandler(ContentHandler ch)
          Set the SAX Content handler that the serializer sends its output to.
 void setDoctype(String system, String pub)
          Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
 void setDoctypePublic(String doctype)
          Set the value coming from the xsl:output doctype-public stylesheet attribute.
 void setDoctypeSystem(String doctype)
          Set the value coming from the xsl:output doctype-system stylesheet attribute.
 void setDocumentLocator(Locator arg0)
          Receive an object for locating the origin of SAX document events.
 void setEncoding(String encoding)
          Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
 boolean setEscaping(boolean escape)
          Turns special character escaping on/off.
 void setIndent(boolean indent)
          Sets the value coming from the xsl:output indent stylesheet attribute.
 void setIndentAmount(int spaces)
          Set the number of spaces to indent for each indentation level.
 void setMediaType(String mediatype)
          Sets the value coming from the xsl:output media-type stylesheet attribute.
 void setNamespaceMappings(NamespaceMappings mappings)
          Used only by TransformerSnapshotImpl to restore the serialization to a previous state.
 void setOmitXMLDeclaration(boolean b)
          Sets the value coming from the xsl:output omit-xml-declaration stylesheet attribute
 void setOutputFormat(Properties format)
          Specifies an output format for this serializer.
 void setOutputStream(OutputStream output)
          Specifies an output stream to which the document should be serialized.
 void setSourceLocator(SourceLocator locator)
          This method is used to set the source locator, which might be used to generated an error message.
 void setStandalone(String standalone)
          Sets the value coming from the xsl:output standalone stylesheet attribute.
 void setTransformer(Transformer transformer)
          Set the transformer associated with the serializer.
 void setVersion(String version)
          Sets the value coming from the xsl:output version attribute.
 void setWriter(Writer writer)
          Specifies a writer to which the document should be serialized.
 void skippedEntity(String arg0)
          Receive notification of a skipped entity.
 void startCDATA()
          Report the start of a CDATA section.
 void startDocument()
          Receive notification of the beginning of a document.
 void startDTD(String arg0, String arg1, String arg2)
          Report the start of DTD declarations, if any.
 void startElement(String qName)
          This method is used to notify of the start of an element
 void startElement(String uri, String localName, String qName)
          This method is used to notify that an element is starting.
 void startElement(String arg0, String arg1, String arg2, Attributes arg3)
          Receive notification of the beginning of an element.
 void startEntity(String arg0)
          Report the beginning of some internal and external XML entities.
 void startPrefixMapping(String arg0, String arg1)
          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.
 void warning(SAXParseException arg0)
          Receive notification of a warning.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmptySerializer

public EmptySerializer()
Method Detail

asContentHandler

public ContentHandler asContentHandler()
                                throws IOException
Description copied from interface: Serializer
Return a ContentHandler interface into this serializer. If the serializer does not support the ContentHandler interface, it should return null.

Specified by:
asContentHandler in interface Serializer
Returns:
A ContentHandler interface into this serializer, or null if the serializer is not SAX 2 capable
Throws:
IOException - An I/O exception occured
See Also:
Serializer.asContentHandler()

setContentHandler

public void setContentHandler(ContentHandler ch)
Description copied from interface: SerializationHandler
Set the SAX Content handler that the serializer sends its output to. This method only applies to a ToSAXHandler, not to a ToStream serializer.

Specified by:
setContentHandler in interface SerializationHandler
See Also:
SerializationHandler.setContentHandler(org.xml.sax.ContentHandler)

close

public void close()
Specified by:
close in interface SerializationHandler
See Also:
SerializationHandler.close()

getOutputFormat

public Properties getOutputFormat()
Description copied from interface: Serializer
Returns the output format properties for this serializer.

Specified by:
getOutputFormat in interface Serializer
Returns:
The output format in use
See Also:
Serializer.getOutputFormat()

getOutputStream

public OutputStream getOutputStream()
Description copied from interface: Serializer
Get the output stream where the events will be serialized to.

Specified by:
getOutputStream in interface Serializer
Returns:
reference to the result stream, or null of only a writer was set.
See Also:
Serializer.getOutputStream()

getWriter

public Writer getWriter()
Description copied from interface: Serializer
Get the character stream where the events will be serialized to.

Specified by:
getWriter in interface Serializer
Returns:
Reference to the result Writer, or null.
See Also:
Serializer.getWriter()

reset

public boolean reset()
Description copied from interface: Serializer
Resets the serializer. If this method returns true, the serializer may be used for subsequent serialization of new documents. It is possible to change the output format and output stream prior to serializing, or to use the existing output format and output stream.

Specified by:
reset in interface Serializer
Returns:
True if serializer has been reset and can be reused
See Also:
Serializer.reset()

serialize

public void serialize(Node node)
               throws IOException
Description copied from interface: SerializationHandler
Notify that the serializer should take this DOM node as input to be serialized.

Specified by:
serialize in interface SerializationHandler
Parameters:
node - the DOM node to be serialized.
Throws:
IOException
See Also:
SerializationHandler.serialize(org.w3c.dom.Node)

setCdataSectionElements

public void setCdataSectionElements(Vector URI_and_localNames)
Description copied from interface: XSLOutputAttributes
Sets the value coming from the xsl:output cdata-section-elements stylesheet property. This sets the elements whose text elements are to be output as CDATA sections.

Specified by:
setCdataSectionElements in interface XSLOutputAttributes
Parameters:
URI_and_localNames - pairs of namespace URI and local names that identify elements whose text elements are to be output as CDATA sections. The namespace of the local element must be the given URI to match. The qName is not given because the prefix does not matter, only the namespace URI to which that prefix would map matters, so the prefix itself is not relevant in specifying which elements have their text to be output as CDATA sections.
See Also:
XSLOutputAttributes.setCdataSectionElements(java.util.Vector)

setEscaping

public boolean setEscaping(boolean escape)
                    throws SAXException
Description copied from interface: SerializationHandler
Turns special character escaping on/off. Note that characters will never, even if this option is set to 'true', be escaped within CDATA sections in output XML documents.

Specified by:
setEscaping in interface SerializationHandler
Throws:
SAXException
See Also:
SerializationHandler.setEscaping(boolean)

setIndent

public void setIndent(boolean indent)
Description copied from interface: XSLOutputAttributes
Sets the value coming from the xsl:output indent stylesheet attribute.

Specified by:
setIndent in interface XSLOutputAttributes
Parameters:
indent - true if the output document should be indented to visually indicate its structure.
See Also:
XSLOutputAttributes.setIndent(boolean)

setIndentAmount

public void setIndentAmount(int spaces)
Description copied from interface: SerializationHandler
Set the number of spaces to indent for each indentation level.

Specified by:
setIndentAmount in interface SerializationHandler
Parameters:
spaces - the number of spaces to indent for each indentation level.
See Also:
SerializationHandler.setIndentAmount(int)

setOutputFormat

public void setOutputFormat(Properties format)
Description copied from interface: Serializer
Specifies an output format for this serializer. It the serializer has already been associated with an output format, it will switch to the new format. This method should not be called while the serializer is in the process of serializing a document.

Specified by:
setOutputFormat in interface Serializer
Parameters:
format - The output format to use
See Also:
Serializer.setOutputFormat(java.util.Properties)

setOutputStream

public void setOutputStream(OutputStream output)
Description copied from interface: Serializer
Specifies an output stream to which the document should be serialized. This method should not be called while the serializer is in the process of serializing a document.

The encoding specified in the output Properties is used, or if no encoding was specified, the default for the selected output method.

Specified by:
setOutputStream in interface Serializer
Parameters:
output - The output stream
See Also:
Serializer.setOutputStream(java.io.OutputStream)

setVersion

public void setVersion(String version)
Description copied from interface: XSLOutputAttributes
Sets the value coming from the xsl:output version attribute.

Specified by:
setVersion in interface XSLOutputAttributes
Parameters:
version - the version of the output format.
See Also:
XSLOutputAttributes.setVersion(java.lang.String)

setWriter

public void setWriter(Writer writer)
Description copied from interface: Serializer
Specifies a writer to which the document should be serialized. This method should not be called while the serializer is in the process of serializing a document.

The encoding specified for the output Properties must be identical to the output format used with the writer.

Specified by:
setWriter in interface Serializer
Parameters:
writer - The output writer stream
See Also:
Serializer.setWriter(java.io.Writer)

setTransformer

public void setTransformer(Transformer transformer)
Description copied from interface: SerializationHandler
Set the transformer associated with the serializer.

Specified by:
setTransformer in interface SerializationHandler
Parameters:
transformer - the transformer associated with the serializer.
See Also:
SerializationHandler.setTransformer(javax.xml.transform.Transformer)

getTransformer

public Transformer getTransformer()
Description copied from interface: SerializationHandler
Get the transformer associated with the serializer.

Specified by:
getTransformer in interface SerializationHandler
Returns:
Transformer the transformer associated with the serializer.
See Also:
SerializationHandler.getTransformer()

flushPending

public void flushPending()
                  throws SAXException
Description copied from interface: SerializationHandler
Flush any pending events currently queued up in the serializer. This will flush any input that the serializer has which it has not yet sent as output.

Specified by:
flushPending in interface SerializationHandler
Throws:
SAXException
See Also:
SerializationHandler.flushPending()

addAttribute

public void addAttribute(String uri,
                         String localName,
                         String rawName,
                         String type,
                         String value)
                  throws SAXException
Description copied from interface: ExtendedContentHandler
Add at attribute to the current element

Specified by:
addAttribute in interface ExtendedContentHandler
Parameters:
uri - the namespace URI of the attribute name
localName - the local name of the attribute (without prefix)
rawName - the qualified name of the attribute
type - the attribute type typically character data (CDATA)
value - the value of the attribute
Throws:
SAXException
See Also:
ExtendedContentHandler.addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

addAttributes

public void addAttributes(Attributes atts)
                   throws SAXException
Description copied from interface: ExtendedContentHandler
Add attributes to the current element

Specified by:
addAttributes in interface ExtendedContentHandler
Parameters:
atts - the attributes to add.
Throws:
SAXException
See Also:
ExtendedContentHandler.addAttributes(org.xml.sax.Attributes)

addAttribute

public void addAttribute(String name,
                         String value)
Description copied from interface: ExtendedContentHandler
Add an attribute to the current element. The namespace URI of the attribute will be calculated from the prefix of qName. The local name will be derived from qName and the type will be assumed to be "CDATA".

Specified by:
addAttribute in interface ExtendedContentHandler
Parameters:
name -
value -
See Also:
ExtendedContentHandler.addAttribute(java.lang.String, java.lang.String)

characters

public void characters(String chars)
                throws SAXException
Description copied from interface: ExtendedContentHandler
This method is used to notify of a character event, but passing the data as a character String rather than the standard character array.

Specified by:
characters in interface ExtendedContentHandler
Parameters:
chars - the character data
Throws:
SAXException
See Also:
ExtendedContentHandler.characters(java.lang.String)

endElement

public void endElement(String elemName)
                throws SAXException
Description copied from interface: ExtendedContentHandler
This method is used to notify that an element has ended. Unlike the standard SAX method
 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.

Specified by:
endElement in interface ExtendedContentHandler
Parameters:
elemName - the fully qualified element name.
Throws:
SAXException
See Also:
ExtendedContentHandler.endElement(java.lang.String)

startDocument

public void startDocument()
                   throws SAXException
Description copied from interface: ContentHandler
Receive notification of the beginning of a document.

The SAX parser will invoke this method only once, before any other event callbacks (except for setDocumentLocator).

Specified by:
startDocument in interface ContentHandler
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.startDocument()

startElement

public void startElement(String uri,
                         String localName,
                         String qName)
                  throws SAXException
Description copied from interface: ExtendedContentHandler
This method is used to notify that an element is starting. This method is just like the standard SAX method
 startElement(uri,localName,qname,atts)
 
but without the attributes.

Specified by:
startElement in interface ExtendedContentHandler
Parameters:
uri - the namespace URI of the element
localName - the local name (without prefix) of the element
qName - the qualified name of the element
Throws:
SAXException
See Also:
ExtendedContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String)

startElement

public void startElement(String qName)
                  throws SAXException
Description copied from interface: ExtendedContentHandler
This method is used to notify of the start of an element

Specified by:
startElement in interface ExtendedContentHandler
Parameters:
qName - the fully qualified name of the element
Throws:
SAXException
See Also:
ExtendedContentHandler.startElement(java.lang.String)

namespaceAfterStartElement

public void namespaceAfterStartElement(String uri,
                                       String prefix)
                                throws SAXException
Description copied from interface: ExtendedContentHandler
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
Parameters:
uri - the namespace URI being declared
prefix - the prefix that maps to the given namespace
Throws:
SAXException
See Also:
ExtendedContentHandler.namespaceAfterStartElement(java.lang.String, java.lang.String)

startPrefixMapping

public boolean startPrefixMapping(String prefix,
                                  String uri,
                                  boolean shouldFlush)
                           throws SAXException
Description copied from interface: ExtendedContentHandler
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
See Also:
ExtendedContentHandler.startPrefixMapping(java.lang.String, java.lang.String, boolean)

entityReference

public void entityReference(String entityName)
                     throws SAXException
Description copied from interface: ExtendedContentHandler
Notify of an entity reference.

Specified by:
entityReference in interface ExtendedContentHandler
Parameters:
entityName - the name of the entity
Throws:
SAXException
See Also:
ExtendedContentHandler.entityReference(java.lang.String)

getNamespaceMappings

public NamespaceMappings getNamespaceMappings()
Description copied from interface: ExtendedContentHandler
This method returns an object that has the current namespace mappings in effect.

Specified by:
getNamespaceMappings in interface ExtendedContentHandler
Returns:
NamespaceMappings an object that has the current namespace mappings in effect.
See Also:
ExtendedContentHandler.getNamespaceMappings()

getPrefix

public String getPrefix(String uri)
Description copied from interface: ExtendedContentHandler
This method returns the prefix that currently maps to the given namespace URI.

Specified by:
getPrefix in interface ExtendedContentHandler
Parameters:
uri - the namespace URI
Returns:
String the prefix that currently maps to the given URI.
See Also:
ExtendedContentHandler.getPrefix(java.lang.String)

getNamespaceURI

public String getNamespaceURI(String name,
                              boolean isElement)
Description copied from interface: ExtendedContentHandler
This method gets the prefix associated with a current element or attribute name.

Specified by:
getNamespaceURI in interface ExtendedContentHandler
Parameters:
name - the qualified name of an element, or attribute
isElement - true if it is an element name, false if it is an atttribute name
Returns:
String the namespace URI associated with the element or attribute.
See Also:
ExtendedContentHandler.getNamespaceURI(java.lang.String, boolean)

getNamespaceURIFromPrefix

public String getNamespaceURIFromPrefix(String prefix)
Description copied from interface: ExtendedContentHandler
This method returns the namespace URI currently associated with the prefix.

Specified by:
getNamespaceURIFromPrefix in interface ExtendedContentHandler
Parameters:
prefix - a prefix of an element or attribute.
Returns:
String the namespace URI currently associated with the prefix.
See Also:
ExtendedContentHandler.getNamespaceURIFromPrefix(java.lang.String)

setDocumentLocator

public void setDocumentLocator(Locator arg0)
Description copied from interface: ContentHandler
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 ContentHandler 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.

Specified by:
setDocumentLocator in interface ContentHandler
Parameters:
arg0 - An object that can return the location of any SAX document event.
See Also:
ContentHandler.setDocumentLocator(org.xml.sax.Locator)

endDocument

public void endDocument()
                 throws SAXException
Description copied from interface: ContentHandler
Receive notification of the end of a document.

The SAX parser will invoke this method only once, and it will be the last method invoked during the parse. The parser shall not invoke this method until it has either abandoned parsing (because of an unrecoverable error) or reached the end of input.

Specified by:
endDocument in interface ContentHandler
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endDocument()

startPrefixMapping

public void startPrefixMapping(String arg0,
                               String arg1)
                        throws SAXException
Description copied from interface: ContentHandler
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:
arg0 - The Namespace prefix being declared. An empty string is used for the default element namespace, which has no prefix.
arg1 - The Namespace URI the prefix is mapped to.
Throws:
SAXException - The client may throw an exception during processing.
See Also:
ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)

endPrefixMapping

public void endPrefixMapping(String arg0)
                      throws SAXException
Description copied from interface: ContentHandler
End the scope of a prefix-URI mapping.

See startPrefixMapping for details. These events will always occur immediately after the corresponding endElement event, but the order of endPrefixMapping events is not otherwise guaranteed.

Specified by:
endPrefixMapping in interface ContentHandler
Parameters:
arg0 - The prefix that was being mapping. This is the empty string when a default mapping scope ends.
Throws:
SAXException - The client may throw an exception during processing.
See Also:
ContentHandler.endPrefixMapping(java.lang.String)

startElement

public void startElement(String arg0,
                         String arg1,
                         String arg2,
                         Attributes arg3)
                  throws SAXException
Description copied from interface: ContentHandler
Receive notification of the beginning of an element.

The Parser will invoke this method at the beginning of every element in the XML document; there will be a corresponding endElement event for every startElement event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding endElement event.

This event allows up to three name components for each element:

  1. the Namespace URI;
  2. the local name; and
  3. the qualified (prefixed) name.

Any or all of these may be provided, depending on the values of the http://xml.org/sax/features/namespaces and the http://xml.org/sax/features/namespace-prefixes properties:

Note that the attribute list provided will contain only attributes with explicit values (specified or defaulted): #IMPLIED attributes will be omitted. The attribute list will contain attributes used for Namespace declarations (xmlns* attributes) only if the http://xml.org/sax/features/namespace-prefixes property is true (it is false by default, and support for a true value is optional).

Like characters(), attribute values may have characters that need more than one char value.

Specified by:
startElement in interface ContentHandler
Parameters:
arg0 - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
arg1 - The local name (without prefix), or the empty string if Namespace processing is not being performed.
arg2 - The qualified name (with prefix), or the empty string if qualified names are not available.
arg3 - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endElement

public void endElement(String arg0,
                       String arg1,
                       String arg2)
                throws SAXException
Description copied from interface: ContentHandler
Receive notification of the end of an element.

The SAX parser will invoke this method at the end of every element in the XML document; there will be a corresponding startElement event for every endElement event (even when the element is empty).

For information on the names, see startElement.

Specified by:
endElement in interface ContentHandler
Parameters:
arg0 - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
arg1 - The local name (without prefix), or the empty string if Namespace processing is not being performed.
arg2 - The qualified XML 1.0 name (with prefix), or the empty string if qualified names are not available.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

characters

public void characters(char[] arg0,
                       int arg1,
                       int arg2)
                throws SAXException
Description copied from interface: ContentHandler
Receive notification of character data.

The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.

The application must not attempt to read from the array outside of the specified range.

Individual characters may consist of more than one Java char value. There are two important cases where this happens, because characters can't be represented in just sixteen bits. In one case, characters are represented in a Surrogate Pair, using two special Unicode values. Such characters are in the so-called "Astral Planes", with a code point above U+FFFF. A second case involves composite characters, such as a base character combining with one or more accent characters.

Your code should not assume that algorithms using char-at-a-time idioms will be working in character units; in some cases they will split characters. This is relevant wherever XML permits arbitrary characters, such as attribute values, processing instruction data, and comments as well as in data reported from this method. It's also generally relevant whenever Java code manipulates internationalized text; the issue isn't unique to XML.

Note that some parsers will report whitespace in element content using the ignorableWhitespace method rather than this one (validating parsers must do so).

Specified by:
characters in interface ContentHandler
Parameters:
arg0 - The characters from the XML document.
arg1 - The start position in the array.
arg2 - The number of characters to read from the array.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.characters(char[], int, int)

ignorableWhitespace

public void ignorableWhitespace(char[] arg0,
                                int arg1,
                                int arg2)
                         throws SAXException
Description copied from interface: ContentHandler
Receive notification of ignorable whitespace in element content.

Validating Parsers must use this method to report each chunk of whitespace in element content (see the W3C XML 1.0 recommendation, section 2.10): non-validating parsers may also use this method if they are capable of parsing and using content models.

SAX parsers may return all contiguous whitespace in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.

The application must not attempt to read from the array outside of the specified range.

Specified by:
ignorableWhitespace in interface ContentHandler
Parameters:
arg0 - The characters from the XML document.
arg1 - The start position in the array.
arg2 - The number of characters to read from the array.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.ignorableWhitespace(char[], int, int)

processingInstruction

public void processingInstruction(String arg0,
                                  String arg1)
                           throws SAXException
Description copied from interface: ContentHandler
Receive notification of a processing instruction.

The Parser will invoke this method once for each processing instruction found: note that processing instructions may occur before or after the main document element.

A SAX parser must never report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.

Like characters(), processing instruction data may have characters that need more than one char value.

Specified by:
processingInstruction in interface ContentHandler
Parameters:
arg0 - The processing instruction target.
arg1 - The processing instruction data, or null if none was supplied. The data does not include any whitespace separating it from the target.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.processingInstruction(java.lang.String, java.lang.String)

skippedEntity

public void skippedEntity(String arg0)
                   throws SAXException
Description copied from interface: ContentHandler
Receive notification of a skipped entity. This is not called for entity references within markup constructs such as element start tags or markup declarations. (The XML recommendation requires reporting skipped external entities. SAX also reports internal entity expansion/non-expansion, except within markup constructs.)

The Parser will invoke this method each time the entity is skipped. Non-validating processors may skip entities if they have not seen the declarations (because, for example, the entity was declared in an external DTD subset). All processors may skip external entities, depending on the values of the http://xml.org/sax/features/external-general-entities and the http://xml.org/sax/features/external-parameter-entities properties.

Specified by:
skippedEntity in interface ContentHandler
Parameters:
arg0 - The name of the skipped entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be the string "[dtd]".
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ContentHandler.skippedEntity(java.lang.String)

comment

public void comment(String comment)
             throws SAXException
Description copied from interface: ExtendedLexicalHandler
This method is used to notify of a comment

Specified by:
comment in interface ExtendedLexicalHandler
Parameters:
comment - the comment, but unlike the SAX comment() method this method takes a String rather than a character array.
Throws:
SAXException
See Also:
ExtendedLexicalHandler.comment(java.lang.String)

startDTD

public void startDTD(String arg0,
                     String arg1,
                     String arg2)
              throws SAXException
Description copied from interface: LexicalHandler
Report the start of DTD declarations, if any.

This method is intended to report the beginning of the DOCTYPE declaration; if the document has no DOCTYPE declaration, this method will not be invoked.

All declarations reported through DTDHandler or DeclHandler events must appear between the startDTD and endDTD events. Declarations are assumed to belong to the internal DTD subset unless they appear between startEntity and endEntity events. Comments and processing instructions from the DTD should also be reported between the startDTD and endDTD events, in their original order of (logical) occurrence; they are not required to appear in their correct locations relative to DTDHandler or DeclHandler events, however.

Note that the start/endDTD events will appear within the start/endDocument events from ContentHandler and before the first startElement event.

Specified by:
startDTD in interface LexicalHandler
Parameters:
arg0 - The document type name.
arg1 - The declared public identifier for the external DTD subset, or null if none was declared.
arg2 - The declared system identifier for the external DTD subset, or null if none was declared. (Note that this is not resolved against the document base URI.)
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.startDTD(java.lang.String, java.lang.String, java.lang.String)

endDTD

public void endDTD()
            throws SAXException
Description copied from interface: LexicalHandler
Report the end of DTD declarations.

This method is intended to report the end of the DOCTYPE declaration; if the document has no DOCTYPE declaration, this method will not be invoked.

Specified by:
endDTD in interface LexicalHandler
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.endDTD()

startEntity

public void startEntity(String arg0)
                 throws SAXException
Description copied from interface: LexicalHandler
Report the beginning of some internal and external XML entities.

The reporting of parameter entities (including the external DTD subset) is optional, and SAX2 drivers that report LexicalHandler events may not implement it; you can use the http://xml.org/sax/features/lexical-handler/parameter-entities feature to query or control the reporting of parameter entities.

General entities are reported with their regular names, parameter entities have '%' prepended to their names, and the external DTD subset has the pseudo-entity name "[dtd]".

When a SAX2 driver is providing these events, all other events must be properly nested within start/end entity events. There is no additional requirement that events from DeclHandler or DTDHandler be properly ordered.

Note that skipped entities will be reported through the skippedEntity event, which is part of the ContentHandler interface.

Because of the streaming event model that SAX uses, some entity boundaries cannot be reported under any circumstances:

These will be silently expanded, with no indication of where the original entity boundaries were.

Note also that the boundaries of character references (which are not really entities anyway) are not reported.

All start/endEntity events must be properly nested.

Specified by:
startEntity in interface LexicalHandler
Parameters:
arg0 - The name of the entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be "[dtd]".
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.startEntity(java.lang.String)

endEntity

public void endEntity(String arg0)
               throws SAXException
Description copied from interface: LexicalHandler
Report the end of an entity.

Specified by:
endEntity in interface LexicalHandler
Parameters:
arg0 - The name of the entity that is ending.
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.endEntity(java.lang.String)

startCDATA

public void startCDATA()
                throws SAXException
Description copied from interface: LexicalHandler
Report the start of a CDATA section.

The contents of the CDATA section will be reported through the regular characters event; this event is intended only to report the boundary.

Specified by:
startCDATA in interface LexicalHandler
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.startCDATA()

endCDATA

public void endCDATA()
              throws SAXException
Description copied from interface: LexicalHandler
Report the end of a CDATA section.

Specified by:
endCDATA in interface LexicalHandler
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.endCDATA()

comment

public void comment(char[] arg0,
                    int arg1,
                    int arg2)
             throws SAXException
Description copied from interface: LexicalHandler
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:
arg0 - An array holding the characters in the comment.
arg1 - The starting position in the array.
arg2 - The number of characters to use from the array.
Throws:
SAXException - The application may raise an exception.
See Also:
LexicalHandler.comment(char[], int, int)

getDoctypePublic

public String getDoctypePublic()
Description copied from interface: XSLOutputAttributes
Returns the previously set value of the value to be used as the public identifier in the document type declaration (DTD).

Specified by:
getDoctypePublic in interface XSLOutputAttributes
Returns:
the public identifier to be used in the DOCTYPE declaration in the output document.
See Also:
XSLOutputAttributes.getDoctypePublic()

getDoctypeSystem

public String getDoctypeSystem()
Description copied from interface: XSLOutputAttributes
Returns the previously set value of the value to be used as the system identifier in the document type declaration (DTD).

Specified by:
getDoctypeSystem in interface XSLOutputAttributes
Returns:
the system identifier to be used in the DOCTYPE declaration in the output document.
See Also:
XSLOutputAttributes.getDoctypeSystem()

getEncoding

public String getEncoding()
Specified by:
getEncoding in interface XSLOutputAttributes
Returns:
the character encoding to be used in the output document.
See Also:
XSLOutputAttributes.getEncoding()

getIndent

public boolean getIndent()
Specified by:
getIndent in interface XSLOutputAttributes
Returns:
true if the output document should be indented to visually indicate its structure.
See Also:
XSLOutputAttributes.getIndent()

getIndentAmount

public int getIndentAmount()
Specified by:
getIndentAmount in interface XSLOutputAttributes
Returns:
the number of spaces to indent for each indentation level.
See Also:
XSLOutputAttributes.getIndentAmount()

getMediaType

public String getMediaType()
Specified by:
getMediaType in interface XSLOutputAttributes
Returns:
the mediatype the media-type or MIME type associated with the output document.
See Also:
XSLOutputAttributes.getMediaType()

getOmitXMLDeclaration

public boolean getOmitXMLDeclaration()
Specified by:
getOmitXMLDeclaration in interface XSLOutputAttributes
Returns:
true if the XML declaration is to be omitted from the output document.
See Also:
XSLOutputAttributes.getOmitXMLDeclaration()

getStandalone

public String getStandalone()
Specified by:
getStandalone in interface XSLOutputAttributes
Returns:
a value of "yes" if the standalone delaration is to be included in the output document.
See Also:
XSLOutputAttributes.getStandalone()

getVersion

public String getVersion()
Specified by:
getVersion in interface XSLOutputAttributes
Returns:
the version of the output format.
See Also:
XSLOutputAttributes.getVersion()

setCdataSectionElements

public void setCdataSectionElements(Hashtable h)
                             throws Exception
Throws:
Exception
See Also:
XSLOutputAttributes.setCdataSectionElements(java.util.Vector)

setDoctype

public void setDoctype(String system,
                       String pub)
Description copied from interface: XSLOutputAttributes
Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties

Specified by:
setDoctype in interface XSLOutputAttributes
Parameters:
system - the system identifier to be used in the DOCTYPE declaration in the output document.
pub - the public identifier to be used in the DOCTYPE declaration in the output document.
See Also:
XSLOutputAttributes.setDoctype(java.lang.String, java.lang.String)

setDoctypePublic

public void setDoctypePublic(String doctype)
Description copied from interface: XSLOutputAttributes
Set the value coming from the xsl:output doctype-public stylesheet attribute.

Specified by:
setDoctypePublic in interface XSLOutputAttributes
Parameters:
doctype - the public identifier to be used in the DOCTYPE declaration in the output document.
See Also:
XSLOutputAttributes.setDoctypePublic(java.lang.String)

setDoctypeSystem

public void setDoctypeSystem(String doctype)
Description copied from interface: XSLOutputAttributes
Set the value coming from the xsl:output doctype-system stylesheet attribute.

Specified by:
setDoctypeSystem in interface XSLOutputAttributes
Parameters:
doctype - the system identifier to be used in the DOCTYPE declaration in the output document.
See Also:
XSLOutputAttributes.setDoctypeSystem(java.lang.String)

setEncoding

public void setEncoding(String encoding)
Description copied from interface: XSLOutputAttributes
Sets the character encoding coming from the xsl:output encoding stylesheet attribute.

Specified by:
setEncoding in interface XSLOutputAttributes
Parameters:
encoding - the character encoding
See Also:
XSLOutputAttributes.setEncoding(java.lang.String)

setMediaType

public void setMediaType(String mediatype)
Description copied from interface: XSLOutputAttributes
Sets the value coming from the xsl:output media-type stylesheet attribute.

Specified by:
setMediaType in interface XSLOutputAttributes
Parameters:
mediatype - the media-type or MIME type associated with the output document.
See Also:
XSLOutputAttributes.setMediaType(java.lang.String)

setOmitXMLDeclaration

public void setOmitXMLDeclaration(boolean b)
Description copied from interface: XSLOutputAttributes
Sets the value coming from the xsl:output omit-xml-declaration stylesheet attribute

Specified by:
setOmitXMLDeclaration in interface XSLOutputAttributes
Parameters:
b - true if the XML declaration is to be omitted from the output document.
See Also:
XSLOutputAttributes.setOmitXMLDeclaration(boolean)

setStandalone

public void setStandalone(String standalone)
Description copied from interface: XSLOutputAttributes
Sets the value coming from the xsl:output standalone stylesheet attribute.

Specified by:
setStandalone in interface XSLOutputAttributes
Parameters:
standalone - a value of "yes" indicates that the standalone delaration is to be included in the output document.
See Also:
XSLOutputAttributes.setStandalone(java.lang.String)

elementDecl

public void elementDecl(String arg0,
                        String arg1)
                 throws SAXException
Description copied from interface: DeclHandler
Report an element type declaration.

The content model will consist of the string "EMPTY", the string "ANY", or a parenthesised group, optionally followed by an occurrence indicator. The model will be normalized so that all parameter entities are fully resolved and all whitespace is removed,and will include the enclosing parentheses. Other normalization (such as removing redundant parentheses or simplifying occurrence indicators) is at the discretion of the parser.

Specified by:
elementDecl in interface DeclHandler
Parameters:
arg0 - The element type name.
arg1 - The content model as a normalized string.
Throws:
SAXException - The application may raise an exception.
See Also:
DeclHandler.elementDecl(java.lang.String, java.lang.String)

attributeDecl

public void attributeDecl(String arg0,
                          String arg1,
                          String arg2,
                          String arg3,
                          String arg4)
                   throws SAXException
Description copied from interface: DeclHandler
Report an attribute type declaration.

Only the effective (first) declaration for an attribute will be reported. The type will be one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", a parenthesized token group with the separator "|" and all whitespace removed, or the word "NOTATION" followed by a space followed by a parenthesized token group with all whitespace removed.

The value will be the value as reported to applications, appropriately normalized and with entity and character references expanded.

Specified by:
attributeDecl in interface DeclHandler
Parameters:
arg0 - The name of the associated element.
arg1 - The name of the attribute.
arg2 - A string representing the attribute type.
arg3 - A string representing the attribute defaulting mode ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies.
arg4 - A string representing the attribute's default value, or null if there is none.
Throws:
SAXException - The application may raise an exception.
See Also:
DeclHandler.attributeDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

internalEntityDecl

public void internalEntityDecl(String arg0,
                               String arg1)
                        throws SAXException
Description copied from interface: DeclHandler
Report an internal entity declaration.

Only the effective (first) declaration for each entity will be reported. All parameter entities in the value will be expanded, but general entities will not.

Specified by:
internalEntityDecl in interface DeclHandler
Parameters:
arg0 - The name of the entity. If it is a parameter entity, the name will begin with '%'.
arg1 - The replacement text of the entity.
Throws:
SAXException - The application may raise an exception.
See Also:
DeclHandler.internalEntityDecl(java.lang.String, java.lang.String)

externalEntityDecl

public void externalEntityDecl(String arg0,
                               String arg1,
                               String arg2)
                        throws SAXException
Description copied from interface: DeclHandler
Report a parsed external entity declaration.

Only the effective (first) declaration for each entity will be reported.

Specified by:
externalEntityDecl in interface DeclHandler
Parameters:
arg0 - The name of the entity. If it is a parameter entity, the name will begin with '%'.
arg1 - The declared public identifier of the entity, or null if none was declared.
arg2 - The declared system identifier of the entity.
Throws:
SAXException - The application may raise an exception.
See Also:
DeclHandler.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)

warning

public void warning(SAXParseException arg0)
             throws SAXException
Description copied from interface: ErrorHandler
Receive notification of a warning.

SAX parsers will use this method to report conditions that are not errors or fatal errors as defined by the XML 1.0 recommendation. The default behaviour is to take no action.

The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end.

Filters may use this method to report other, non-XML warnings as well.

Specified by:
warning in interface ErrorHandler
Parameters:
arg0 - The warning information encapsulated in a SAX parse exception.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ErrorHandler.warning(org.xml.sax.SAXParseException)

error

public void error(SAXParseException arg0)
           throws SAXException
Description copied from interface: ErrorHandler
Receive notification of a recoverable error.

This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a validating parser would use this callback to report the violation of a validity constraint. The default behaviour is to take no action.

The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end. If the application cannot do so, then the parser should report a fatal error even if the XML 1.0 recommendation does not require it to do so.

Filters may use this method to report other, non-XML errors as well.

Specified by:
error in interface ErrorHandler
Parameters:
arg0 - The error information encapsulated in a SAX parse exception.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ErrorHandler.error(org.xml.sax.SAXParseException)

fatalError

public void fatalError(SAXParseException arg0)
                throws SAXException
Description copied from interface: ErrorHandler
Receive notification of a non-recoverable error.

This corresponds to the definition of "fatal error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a parser would use this callback to report the violation of a well-formedness constraint.

The application must assume that the document is unusable after the parser has invoked this method, and should continue (if at all) only for the sake of collecting addition error messages: in fact, SAX parsers are free to stop reporting any other events once this method has been invoked.

Specified by:
fatalError in interface ErrorHandler
Parameters:
arg0 - The error information encapsulated in a SAX parse exception.
Throws:
SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
ErrorHandler.fatalError(org.xml.sax.SAXParseException)

asDOMSerializer

public DOMSerializer asDOMSerializer()
                              throws IOException
Description copied from interface: Serializer
Return a DOMSerializer interface into this serializer. If the serializer does not support the DOMSerializer interface, it should return null.

Specified by:
asDOMSerializer in interface Serializer
Returns:
A DOMSerializer interface into this serializer, or null if the serializer is not DOM capable
Throws:
IOException - An I/O exception occured
See Also:
Serializer.asDOMSerializer()

setNamespaceMappings

public void setNamespaceMappings(NamespaceMappings mappings)
Description copied from interface: SerializationHandler
Used only by TransformerSnapshotImpl to restore the serialization to a previous state.

Specified by:
setNamespaceMappings in interface SerializationHandler
See Also:
SerializationHandler.setNamespaceMappings(NamespaceMappings)

setSourceLocator

public void setSourceLocator(SourceLocator locator)
Description copied from interface: ExtendedContentHandler
This method is used to set the source locator, which might be used to generated an error message.

Specified by:
setSourceLocator in interface ExtendedContentHandler
Parameters:
locator - the source locator
See Also:
ExtendedContentHandler.setSourceLocator(javax.xml.transform.SourceLocator)

addUniqueAttribute

public void addUniqueAttribute(String name,
                               String value,
                               int flags)
                        throws SAXException
Description copied from interface: ExtendedContentHandler
Add a unique attribute to the current element. The attribute is guaranteed to be unique here. The serializer can write it out immediately without saving it in a table first. The integer flag contains information about the attribute, which helps the serializer to decide whether a particular processing is needed.

Specified by:
addUniqueAttribute in interface ExtendedContentHandler
Parameters:
name - the fully qualified attribute name.
value - the attribute value
flags - a bitwise flag
Throws:
SAXException
See Also:
ExtendedContentHandler.addUniqueAttribute(java.lang.String, java.lang.String, int)


Copyright ? 2004 Apache XML Project. All Rights Reserved.