Top Description Fields Constructors Methods
com.sun.org.apache.xml.internal.serializer

public final Class ToXMLSAXHandler

extends ToSAXHandler
Class Inheritance
Imports
java.io.IOException, .OutputStream, .Writer, java.util.Properties, javax.xml.transform.Result, org.w3c.dom.Node, org.xml.sax.Attributes, .ContentHandler, .Locator, .SAXException, org.xml.sax.ext.LexicalHandler

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.

Field Summary

Modifier and TypeField and Description
protected boolean
m_escapeSetting

Keeps track of whether output escaping is currently enabled

Inherited from com.sun.org.apache.xml.internal.serializer.ToSAXHandler:
m_lexHandlerm_saxHandlerm_state

Constructor Summary

AccessConstructor and Description
public
public
public

Method Summary

Modifier and TypeMethod and Description
public void
addAttribute(String
the URI of the attribute
uri
,
String
the local name of the attribute
localName
,
String
the qualified name of the attribute
rawName
,
String
the type of the attribute (probably CDATA)
type
,
String
the value of the attribute
value
,
boolean
true if this attribute is coming from an xsl:attribute element
XSLAttribute
)

Overrides com.sun.org.apache.xml.internal.serializer.SerializerBase.addAttribute.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.addAttribute.

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.

public void
attributeDecl(String
The name of the associated element.
arg0
,
String
The name of the attribute.
arg1
,
String
A string representing the attribute type.
arg2
,
String
A string representing the attribute defaulting mode ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies.
arg3
,
String
A string representing the attribute's default value, or null if there is none.
arg4
)

Implements org.xml.sax.ext.DeclHandler.attributeDecl.

Report an attribute type declaration.

public void
characters(String
The string of characters to process.
chars
)

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.characters.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.characters.

Receive notification of character data.

public void
characters(char[]
the characters from the XML document
ch
,
int
the start position in the array
off
,
int
the number of characters to read from the array
len
)

Implements org.xml.sax.ContentHandler.characters.

Receive notification of character data.

public void
closeCDATA()

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.closeCDATA.

Closes ane open cdata tag, and unlike the this.endCDATA() method (from the LexicalHandler) interface, this "internal" method will send the endCDATA() call to the wrapped handler.

protected void
closeStartTag()

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.closeStartTag.

This method is called when all the data needed for a call to the SAX handler's startElement() method has been gathered.

public void
comment(char[]
An array holding the characters in the comment.
arg0
,
int
The starting position in the array.
arg1
,
int
The number of characters to use from the array.
arg2
)

Implements org.xml.sax.ext.LexicalHandler.comment.

Report an XML comment anywhere in the document.

public void
elementDecl(String
The element type name.
arg0
,
String
The content model as a normalized string.
arg1
)

Implements org.xml.sax.ext.DeclHandler.elementDecl.

Report an element type declaration.

public void
endCDATA()

Implements org.xml.sax.ext.LexicalHandler.endCDATA.

Report the end of a CDATA section.

public void
endDocument()

Implements org.xml.sax.ContentHandler.endDocument.

Receives notification of the end of the document.

public void
endDTD()

Implements org.xml.sax.ext.LexicalHandler.endDTD.

Report the end of DTD declarations.

public void
endElement(String
the Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed
namespaceURI
,
String
the local name (without prefix), or the empty string if Namespace processing is not being performed
localName
,
String
the qualified XML name (with prefix), or the empty string if qualified names are not available
qName
)

Implements org.xml.sax.ContentHandler.endElement.

Receive notification of the end of an element.

public void
endElement(String
the fully qualified element name.
elemName
)

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.endElement.

This method is used to notify that an element has ended.

public void
endPrefixMapping(String
the prefix that was being mapped. This is the empty string when a default mapping scope ends.
prefix
)

Implements org.xml.sax.ContentHandler.endPrefixMapping.

End the scope of a prefix-URI mapping.

private void
public void
externalEntityDecl(String
The name of the entity. If it is a parameter entity, the name will begin with '%'.
arg0
,
String
The entity's public identifier, or null if none was given.
arg1
,
String
The entity's system identifier.
arg2
)

Implements org.xml.sax.ext.DeclHandler.externalEntityDecl.

Report a parsed external entity declaration.

public Properties
getOutputFormat()

Implements com.sun.org.apache.xml.internal.serializer.Serializer.getOutputFormat.

Returns the output format properties for this serializer.

public OutputStream
getOutputStream()

Implements com.sun.org.apache.xml.internal.serializer.Serializer.getOutputStream.

Get the output stream where the events will be serialized to.

public Writer
getWriter()

Implements com.sun.org.apache.xml.internal.serializer.Serializer.getWriter.

Get the character stream where the events will be serialized to.

public void
ignorableWhitespace(char[]
the characters from the XML document
arg0
,
int
the start position in the array
arg1
,
int
the number of characters to read from the array
arg2
)

Implements org.xml.sax.ContentHandler.ignorableWhitespace.

Receive notification of ignorable whitespace in element content.

public void
indent(int n)

Do nothing for SAX.

public void
internalEntityDecl(String
The name of the entity. If it is a parameter entity, the name will begin with '%'.
arg0
,
String
The replacement text of the entity.
arg1
)

Implements org.xml.sax.ext.DeclHandler.internalEntityDecl.

Report an internal entity declaration.

public void
namespaceAfterStartElement(final String
the URI of the namespace
prefix
,
final String
the prefix associated with the given URI.
uri
)

Overrides com.sun.org.apache.xml.internal.serializer.SerializerBase.namespaceAfterStartElement.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.namespaceAfterStartElement.

Send a namespace declaration in the output document.

protected boolean
popNamespace(String prefix)

Undeclare the namespace that is currently pointed to by a given prefix.

public void
processingInstruction(String
the processing instruction target
target
,
String
the processing instruction data, or null if none was supplied. The data does not include any whitespace separating it from the target
data
)

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.processingInstruction.

Implements org.xml.sax.ContentHandler.processingInstruction.

Do nothing as this is an abstract class.

public boolean

Returns:

true if the class was successfuly reset.
reset
()

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.reset.

Implements com.sun.org.apache.xml.internal.serializer.Serializer.reset.

Try's to reset the super class and reset this class for re-use, so that you don't need to create a new serializer (mostly for performance reasons).

private void
resetToXMLSAXHandler()

Reset all of the fields owned by ToXMLSAXHandler class

public void
serialize(Node
the DOM node to be serialized.
node
)

Implements com.sun.org.apache.xml.internal.serializer.SerializationHandler.serialize.

Notify that the serializer should take this DOM node as input to be serialized.

public void
setDocumentLocator(Locator
An object that can return the location of any SAX document event. Receive an object for locating the origin of SAX document events.

SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface.

The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application's business rules). The information returned by the locator is probably not sufficient for use with a search engine.

Note that the locator will return correct information only during the invocation of the events in this interface. The application should not attempt to use it at any other time.

arg0
)

Overrides com.sun.org.apache.xml.internal.serializer.SerializerBase.setDocumentLocator.

Implements org.xml.sax.ContentHandler.setDocumentLocator.

Receive an object for locating the origin of SAX document events.

public boolean
setEscaping(boolean
true if escaping is to be set on.
escape
)

Implements com.sun.org.apache.xml.internal.serializer.SerializationHandler.setEscaping.

Turns special character escaping on/off.

public void
setOutputFormat(Properties
The output format to use, as a set of key/value pairs.
format
)

Implements com.sun.org.apache.xml.internal.serializer.Serializer.setOutputFormat.

Specifies an output format for this serializer.

public void
setOutputStream(OutputStream
The output stream
output
)

Implements com.sun.org.apache.xml.internal.serializer.Serializer.setOutputStream.

Specifies an output stream to which the document should be serialized.

public void
setWriter(Writer
The output writer stream
writer
)

Implements com.sun.org.apache.xml.internal.serializer.Serializer.setWriter.

Specifies a writer to which the document should be serialized.

public void
skippedEntity(String
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]"
arg0
)

Implements org.xml.sax.ContentHandler.skippedEntity.

Receive notification of a skipped entity.

public void
startCDATA()

Implements org.xml.sax.ext.LexicalHandler.startCDATA.

Report the start of a CDATA section.

public void
startElement(String
the URI of the namespace of the element (optional)
elementNamespaceURI
,
String
the element name, but without prefix (optional)
elementLocalName
,
String
the element name, with prefix, if any (required)
elementName
)

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.startElement.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.startElement.

Start an element in the output document.</elem>

public void
startElement(String
the element name, with prefix (if any).
elementName
)

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.startElement.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.startElement.

An element starts, but attributes are not fully known yet.

public void
startElement(String
the Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed
namespaceURI
,
String
the local name (without prefix), or the empty string if Namespace processing is not being performed
localName
,
String
the qualified name (with prefix), or the empty string if qualified names are not available
name
,
Attributes
the attributes attached to the element. If there are no attributes, it shall be an empty Attributes object. The value of this object after startElement returns is undefined
atts
)

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Receive notification of the beginning of an element, although this is a SAX method additional namespace or attribute information can occur before or after this call, that is associated with this element.

public void
startEntity(String
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]".
arg0
)

Implements org.xml.sax.ext.LexicalHandler.startEntity.

Report the beginning of some internal and external XML entities.

public void
startPrefixMapping(String
The prefix that maps to the URI
prefix
,
String
The URI for the namespace
uri
)

Implements org.xml.sax.ContentHandler.startPrefixMapping.

Begin the scope of a prefix-URI Namespace mapping.

public boolean
startPrefixMapping(String
The prefix that maps to the URI
prefix
,
String
The URI for the namespace
uri
,
boolean
a flag indicating if the mapping applies to the current element or an up coming child (not used).
shouldFlush
)

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.startPrefixMapping.

Remember the prefix/uri mapping at the current nested element depth.

Inherited from com.sun.org.apache.xml.internal.serializer.ToSAXHandler:
addUniqueAttributecharacterscommenterrorfatalErrorflushPendinggetShouldOutputNSAttrsetCdataSectionElementssetContentHandlersetLexHandlersetShouldOutputNSAttrsetTransformStatestartDocumentInternalstartDTDwarning

Field Detail

m_escapeSettingback to summary
protected boolean m_escapeSetting

Keeps track of whether output escaping is currently enabled

Constructor Detail

ToXMLSAXHandlerback to summary
public ToXMLSAXHandler()
ToXMLSAXHandlerback to summary
public ToXMLSAXHandler(ContentHandler handler, String encoding)
ToXMLSAXHandlerback to summary
public ToXMLSAXHandler(ContentHandler handler, LexicalHandler lex, String encoding)

Method Detail

addAttributeback to summary
public void addAttribute(String uri, String localName, String rawName, String type, String value, boolean XSLAttribute) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.SerializerBase.addAttribute.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.addAttribute.

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.

Parameters
uri:String

the URI of the attribute

localName:String

the local name of the attribute

rawName:String

the qualified name of the attribute

type:String

the type of the attribute (probably CDATA)

value:String

the value of the attribute

XSLAttribute:boolean

true if this attribute is coming from an xsl:attribute element

See Also
ExtendedContentHandler#addAttribute(String, String, String, String, String)
attributeDeclback to summary
public void attributeDecl(String arg0, String arg1, String arg2, String arg3, String arg4) throws SAXException

Implements org.xml.sax.ext.DeclHandler.attributeDecl.

Doc from org.xml.sax.ext.DeclHandler.attributeDecl.

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.

Parameters
arg0:String

The name of the associated element.

arg1:String

The name of the attribute.

arg2:String

A string representing the attribute type.

arg3:String

A string representing the attribute defaulting mode ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies.

arg4:String

A string representing the attribute's default value, or null if there is none.

Exceptions
SAXException:
The application may raise an exception.
See Also
org.xml.sax.ext.DeclHandler#attributeDecl(String, String, String, String, String)
charactersback to summary
public void characters(String chars) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.characters.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.characters.

Doc from com.sun.org.apache.xml.internal.serializer.ToSAXHandler.characters.

Receive notification of character data.

Parameters
chars:String

The string of characters to process.

See Also
ExtendedContentHandler#characters(String)
charactersback to summary
public void characters(char[] ch, int off, int len) throws SAXException

Implements org.xml.sax.ContentHandler.characters.

Doc from org.xml.sax.ContentHandler.characters.

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).

Parameters
ch:char[]

the characters from the XML document

off:int

the start position in the array

len:int

the number of characters to read from the array

Exceptions
SAXException:
any SAX exception, possibly wrapping another exception
closeCDATAback to summary
public void closeCDATA() throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.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.

closeStartTagback to summary
protected void closeStartTag() throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.closeStartTag.

This method is called when all the data needed for a call to the SAX handler's startElement() method has been gathered.

commentback to summary
public void comment(char[] arg0, int arg1, int arg2) throws SAXException

Implements org.xml.sax.ext.LexicalHandler.comment.

Doc from org.xml.sax.ext.LexicalHandler.comment.

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).

Parameters
arg0:char[]

An array holding the characters in the comment.

arg1:int

The starting position in the array.

arg2:int

The number of characters to use from the array.

Exceptions
SAXException:
The application may raise an exception.
See Also
org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
elementDeclback to summary
public void elementDecl(String arg0, String arg1) throws SAXException

Implements org.xml.sax.ext.DeclHandler.elementDecl.

Doc from org.xml.sax.ext.DeclHandler.elementDecl.

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.

Parameters
arg0:String

The element type name.

arg1:String

The content model as a normalized string.

Exceptions
SAXException:
The application may raise an exception.
See Also
org.xml.sax.ext.DeclHandler#elementDecl(String, String)
endCDATAback to summary
public void endCDATA() throws SAXException

Implements org.xml.sax.ext.LexicalHandler.endCDATA.

Doc from org.xml.sax.ext.LexicalHandler.endCDATA.

Report the end of a CDATA section.

Exceptions
SAXException:
The application may raise an exception.
See Also
org.xml.sax.ext.LexicalHandler#endCDATA()
endDocumentback to summary
public void endDocument() throws SAXException

Implements org.xml.sax.ContentHandler.endDocument.

Receives notification of the end of the document.

Exceptions
SAXException:

Doc from org.xml.sax.ContentHandler.endDocument.

any SAX exception, possibly wrapping another exception

See Also
org.xml.sax.ContentHandler#endDocument()
endDTDback to summary
public void endDTD() throws SAXException

Implements org.xml.sax.ext.LexicalHandler.endDTD.

Doc from org.xml.sax.ext.LexicalHandler.endDTD.

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.

Exceptions
SAXException:
The application may raise an exception.
See Also
org.xml.sax.ext.LexicalHandler#endDTD()
endElementback to summary
public void endElement(String namespaceURI, String localName, String qName) throws SAXException

Implements org.xml.sax.ContentHandler.endElement.

Doc from org.xml.sax.ContentHandler.endElement.

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.

Parameters
namespaceURI:String

the Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed

localName:String

the local name (without prefix), or the empty string if Namespace processing is not being performed

qName:String

the qualified XML name (with prefix), or the empty string if qualified names are not available

Exceptions
SAXException:
any SAX exception, possibly wrapping another exception
See Also
org.xml.sax.ContentHandler#endElement(String, String, String)
endElementback to summary
public void endElement(String elemName) throws SAXException

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.endElement.

Doc from com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.endElement.

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.
Parameters
elemName:String

the fully qualified element name.

See Also
ExtendedContentHandler#endElement(String)
endPrefixMappingback to summary
public void endPrefixMapping(String prefix) throws SAXException

Implements org.xml.sax.ContentHandler.endPrefixMapping.

Doc from org.xml.sax.ContentHandler.endPrefixMapping.

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.

Parameters
prefix:String

the prefix that was being mapped. This is the empty string when a default mapping scope ends.

Exceptions
SAXException:
the client may throw an exception during processing
See Also
org.xml.sax.ContentHandler#endPrefixMapping(String)
ensurePrefixIsDeclaredback to summary
private void ensurePrefixIsDeclared(String ns, String rawName) throws SAXException
externalEntityDeclback to summary
public void externalEntityDecl(String arg0, String arg1, String arg2) throws SAXException

Implements org.xml.sax.ext.DeclHandler.externalEntityDecl.

Doc from org.xml.sax.ext.DeclHandler.externalEntityDecl.

Report a parsed external entity declaration.

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

If the system identifier is a URL, the parser must resolve it fully before passing it to the application.

Parameters
arg0:String

The name of the entity. If it is a parameter entity, the name will begin with '%'.

arg1:String

The entity's public identifier, or null if none was given.

arg2:String

The entity's system identifier.

Exceptions
SAXException:
The application may raise an exception.
See Also
org.xml.sax.ext.DeclHandler#externalEntityDecl(String, String, String)
getOutputFormatback to summary
public Properties getOutputFormat()

Implements com.sun.org.apache.xml.internal.serializer.Serializer.getOutputFormat.

Doc from com.sun.org.apache.xml.internal.serializer.Serializer.getOutputFormat.

Returns the output format properties for this serializer.

Returns:Properties

The output format key/value pairs in use.

See Also
Serializer#getOutputFormat()
getOutputStreamback to summary
public OutputStream getOutputStream()

Implements com.sun.org.apache.xml.internal.serializer.Serializer.getOutputStream.

Doc from com.sun.org.apache.xml.internal.serializer.Serializer.getOutputStream.

Get the output stream where the events will be serialized to.

Returns:OutputStream

reference to the result stream, or null if only a writer was set.

See Also
Serializer#getOutputStream()
getWriterback to summary
public Writer getWriter()

Implements com.sun.org.apache.xml.internal.serializer.Serializer.getWriter.

Doc from com.sun.org.apache.xml.internal.serializer.Serializer.getWriter.

Get the character stream where the events will be serialized to.

Returns:Writer

Reference to the result Writer, or null.

See Also
Serializer#getWriter()
ignorableWhitespaceback to summary
public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws SAXException

Implements org.xml.sax.ContentHandler.ignorableWhitespace.

Doc from org.xml.sax.ContentHandler.ignorableWhitespace.

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.

Parameters
arg0:char[]

the characters from the XML document

arg1:int

the start position in the array

arg2:int

the number of characters to read from the array

Exceptions
SAXException:
any SAX exception, possibly wrapping another exception
See Also
org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
indentback to summary
public void indent(int n) throws SAXException

Do nothing for SAX.

internalEntityDeclback to summary
public void internalEntityDecl(String arg0, String arg1) throws SAXException

Implements org.xml.sax.ext.DeclHandler.internalEntityDecl.

Doc from org.xml.sax.ext.DeclHandler.internalEntityDecl.

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.

Parameters
arg0:String

The name of the entity. If it is a parameter entity, the name will begin with '%'.

arg1:String

The replacement text of the entity.

Exceptions
SAXException:
The application may raise an exception.
See Also
org.xml.sax.ext.DeclHandler#internalEntityDecl(String, String)
namespaceAfterStartElementback to summary
public void namespaceAfterStartElement(final String prefix, final String uri) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.SerializerBase.namespaceAfterStartElement.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.namespaceAfterStartElement.

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.

Parameters
prefix:String

Doc from com.sun.org.apache.xml.internal.serializer.SerializerBase.namespaceAfterStartElement.

the URI of the namespace

uri:String

Doc from com.sun.org.apache.xml.internal.serializer.SerializerBase.namespaceAfterStartElement.

the prefix associated with the given URI.

popNamespaceback to summary
protected boolean popNamespace(String prefix)

Undeclare the namespace that is currently pointed to by a given prefix. Inform SAX handler if prefix was previously mapped.

processingInstructionback to summary
public void processingInstruction(String target, String data) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.processingInstruction.

Implements org.xml.sax.ContentHandler.processingInstruction.

Doc from com.sun.org.apache.xml.internal.serializer.ToSAXHandler.processingInstruction.

Do nothing as this is an abstract class. All subclasses will need to define their behavior if it is different.

Parameters
target:String

Doc from org.xml.sax.ContentHandler.processingInstruction.

the processing instruction target

data:String

Doc from org.xml.sax.ContentHandler.processingInstruction.

the processing instruction data, or null if none was supplied. The data does not include any whitespace separating it from the target

Exceptions
SAXException:

Doc from org.xml.sax.ContentHandler.processingInstruction.

any SAX exception, possibly wrapping another exception

See Also
Send a processing instruction to the output document
resetback to summary
public boolean reset()

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.reset.

Implements com.sun.org.apache.xml.internal.serializer.Serializer.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).

Returns:boolean

true if the class was successfuly reset.

See Also
Serializer#reset()
resetToXMLSAXHandlerback to summary
private void resetToXMLSAXHandler()

Reset all of the fields owned by ToXMLSAXHandler class

serializeback to summary
public void serialize(Node node) throws IOException

Implements com.sun.org.apache.xml.internal.serializer.SerializationHandler.serialize.

Doc from com.sun.org.apache.xml.internal.serializer.SerializationHandler.serialize.

Notify that the serializer should take this DOM node as input to be serialized.

Parameters
node:Node

the DOM node to be serialized.

Exceptions
IOException:

Doc from com.sun.org.apache.xml.internal.serializer.DOMSerializer.serialize.

if an I/O exception occured while serializing

See Also
DOMSerializer#serialize(Node)
setDocumentLocatorback to summary
public void setDocumentLocator(Locator arg0)

Overrides com.sun.org.apache.xml.internal.serializer.SerializerBase.setDocumentLocator.

Implements org.xml.sax.ContentHandler.setDocumentLocator.

Doc from com.sun.org.apache.xml.internal.serializer.SerializerBase.setDocumentLocator.

Receive an object for locating the origin of SAX document events.

Parameters
arg0:Locator

An object that can return the location of any SAX document event. Receive an object for locating the origin of SAX document events.

SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface.

The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application's business rules). The information returned by the locator is probably not sufficient for use with a search engine.

Note that the locator will return correct information only during the invocation of the events in this interface. The application should not attempt to use it at any other time.

See Also
org.xml.sax.ContentHandler#setDocumentLocator(Locator)
setEscapingback to summary
public boolean setEscaping(boolean escape) throws SAXException

Implements com.sun.org.apache.xml.internal.serializer.SerializationHandler.setEscaping.

Doc from com.sun.org.apache.xml.internal.serializer.SerializationHandler.setEscaping.

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.

Parameters
escape:boolean

true if escaping is to be set on.

See Also
SerializationHandler#setEscaping(boolean)
setOutputFormatback to summary
public void setOutputFormat(Properties format)

Implements com.sun.org.apache.xml.internal.serializer.Serializer.setOutputFormat.

Doc from com.sun.org.apache.xml.internal.serializer.Serializer.setOutputFormat.

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.

The standard property keys supported are: "method", "version", "encoding", "omit-xml-declaration", "standalone", doctype-public", "doctype-system", "cdata-section-elements", "indent", "media-type". These property keys and their values are described in the XSLT recommendation, see href="http://www.w3.org/TR/1999/REC-xslt-19991116"> XSLT 1.0 recommendation</a>

The non-standard property keys supported are defined in OutputPropertiesFactory.

This method can be called multiple times before a document is serialized. Each time it is called more, or over-riding property values, can be specified. One property value that can not be changed is that of the "method" property key.

The value of the "cdata-section-elements" property key is a whitespace separated list of elements. If the element is in a namespace then value is passed in this format: {uri}localName

If the "cdata-section-elements" key is specified on multiple calls to this method the set of elements specified in the value is not replaced from one call to the next, but it is cumulative across the calls.

Parameters
format:Properties

The output format to use, as a set of key/value pairs.

See Also
Serializer#setOutputFormat(Properties)
setOutputStreamback to summary
public void setOutputStream(OutputStream output)

Implements com.sun.org.apache.xml.internal.serializer.Serializer.setOutputStream.

Doc from com.sun.org.apache.xml.internal.serializer.Serializer.setOutputStream.

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.

Only one of setWriter() or setOutputStream() should be called.

Parameters
output:OutputStream

The output stream

See Also
Serializer#setOutputStream(OutputStream)
setWriterback to summary
public void setWriter(Writer writer)

Implements com.sun.org.apache.xml.internal.serializer.Serializer.setWriter.

Doc from com.sun.org.apache.xml.internal.serializer.Serializer.setWriter.

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.

Only one of setWriter() or setOutputStream() should be called.

Parameters
writer:Writer

The output writer stream

See Also
Serializer#setWriter(Writer)
skippedEntityback to summary
public void skippedEntity(String arg0) throws SAXException

Implements org.xml.sax.ContentHandler.skippedEntity.

Doc from org.xml.sax.ContentHandler.skippedEntity.

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.

Parameters
arg0:String

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]"

Exceptions
SAXException:
any SAX exception, possibly wrapping another exception
See Also
org.xml.sax.ContentHandler#skippedEntity(String)
startCDATAback to summary
public void startCDATA() throws SAXException

Implements org.xml.sax.ext.LexicalHandler.startCDATA.

Doc from org.xml.sax.ext.LexicalHandler.startCDATA.

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.

Exceptions
SAXException:
The application may raise an exception.
startElementback to summary
public void startElement(String elementNamespaceURI, String elementLocalName, String elementName) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.startElement.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.startElement.

Start an element in the output document. This might be an XML element (data type) or a CDATA section.

Parameters
elementNamespaceURI:String

Doc from com.sun.org.apache.xml.internal.serializer.ToSAXHandler.startElement.

the URI of the namespace of the element (optional)

elementLocalName:String

Doc from com.sun.org.apache.xml.internal.serializer.ToSAXHandler.startElement.

the element name, but without prefix (optional)

elementName:String

Doc from com.sun.org.apache.xml.internal.serializer.ToSAXHandler.startElement.

the element name, with prefix, if any (required)

startElementback to summary
public void startElement(String elementName) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.startElement.

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.startElement.

Doc from com.sun.org.apache.xml.internal.serializer.ToSAXHandler.startElement.

An element starts, but attributes are not fully known yet.

Parameters
elementName:String

the element name, with prefix (if any).

startElementback to summary
public void startElement(String namespaceURI, String localName, String name, Attributes atts) throws SAXException

Overrides com.sun.org.apache.xml.internal.serializer.ToSAXHandler.startElement.

Implements org.xml.sax.ContentHandler.startElement.

Doc from com.sun.org.apache.xml.internal.serializer.ToSAXHandler.startElement.

Receive notification of the beginning of an element, although this is a SAX method additional namespace or attribute information can occur before or after this call, that is associated with this element.

Parameters
namespaceURI:String

Doc from org.xml.sax.ContentHandler.startElement.

the Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed

localName:String

Doc from org.xml.sax.ContentHandler.startElement.

the local name (without prefix), or the empty string if Namespace processing is not being performed

name:String

Doc from org.xml.sax.ContentHandler.startElement.

the qualified name (with prefix), or the empty string if qualified names are not available

atts:Attributes

Doc from org.xml.sax.ContentHandler.startElement.

the attributes attached to the element. If there are no attributes, it shall be an empty Attributes object. The value of this object after startElement returns is undefined

Exceptions
SAXException:
Any SAX exception, possibly wrapping another exception.
See Also
org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
startEntityback to summary
public void startEntity(String arg0) throws SAXException

Implements org.xml.sax.ext.LexicalHandler.startEntity.

Doc from org.xml.sax.ext.LexicalHandler.startEntity.

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:

  • general entities within attribute values
  • parameter entities within declarations

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.

Parameters
arg0:String

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]".

Exceptions
SAXException:
The application may raise an exception.
See Also
org.xml.sax.ext.LexicalHandler#startEntity(String)
startPrefixMappingback to summary
public void startPrefixMapping(String prefix, String uri) throws SAXException

Implements org.xml.sax.ContentHandler.startPrefixMapping.

Doc from org.xml.sax.ContentHandler.startPrefixMapping.

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.

Parameters
prefix:String

The prefix that maps to the URI

uri:String

The URI for the namespace

Exceptions
SAXException:
the client may throw an exception during processing
See Also
org.xml.sax.ContentHandler#startPrefixMapping(String, String)
startPrefixMappingback to summary
public boolean startPrefixMapping(String prefix, String uri, boolean shouldFlush) throws SAXException

Implements com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.startPrefixMapping.

Remember the prefix/uri mapping at the current nested element depth.

Parameters
prefix:String

The prefix that maps to the URI

uri:String

The URI for the namespace

shouldFlush:boolean

a flag indicating if the mapping applies to the current element or an up coming child (not used).

Returns:boolean

Doc from com.sun.org.apache.xml.internal.serializer.ExtendedContentHandler.startPrefixMapping.

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.

See Also
org.xml.sax.ContentHandler#startPrefixMapping(String, String)