Modifier and Type | Field and Description |
---|---|
protected boolean | m_escapeSetting
Keeps track of whether output escaping is currently enabled |
Access | Constructor and Description |
---|---|
public | |
public | |
public |
Modifier and Type | Method 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. Implements com. 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. Report an attribute type declaration. |
public void | characters(String
The string of characters to process. chars)Overrides com. Implements com. 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. Receive notification of character data. |
public void | closeCDATA()
Overrides com. 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. 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. 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. Report an element type declaration. |
public void | |
public void | endDocument()
Implements org. Receives notification of the end of the document. |
public void | |
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. Receive notification of the end of an element. |
public void | endElement(String
the fully qualified element name. elemName)Implements com. 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. 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. Report a parsed external entity declaration. |
public Properties | getOutputFormat()
Implements com. Returns the output format properties for this serializer. |
public OutputStream | getOutputStream()
Implements com. Get the output stream where the events will be serialized to. |
public Writer | getWriter()
Implements com. 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. Receive notification of ignorable whitespace in element content. |
public void | |
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. 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. Implements com. Send a namespace declaration in the output document. |
protected boolean | |
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. Implements org. Do nothing as this is an abstract class. |
public boolean | Returns: true if the class was successfuly reset.Overrides com. Implements com. 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 | |
public void | serialize(Node
the DOM node to be serialized. node)Implements com. 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.
arg0)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. Overrides com. Implements org. 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. 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. Specifies an output format for this serializer. |
public void | setOutputStream(OutputStream
The output stream output)Implements com. Specifies an output stream to which the document should be serialized. |
public void | setWriter(Writer
The output writer stream writer)Implements com. 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. Receive notification of a skipped entity. |
public void | startCDATA()
Implements org. 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. Implements com. Start an element in the output document.</elem> |
public void | startElement(String
the element name, with prefix (if any). elementName)Overrides com. Implements com. 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. Implements org. 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. 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. 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. Remember the prefix/uri mapping at the current nested element depth. |
m_escapeSetting | back to summary |
---|---|
protected boolean m_escapeSetting Keeps track of whether output escaping is currently enabled |
ToXMLSAXHandler | back to summary |
---|---|
public ToXMLSAXHandler() |
ToXMLSAXHandler | back to summary |
---|---|
public ToXMLSAXHandler(ContentHandler handler, String encoding) |
ToXMLSAXHandler | back to summary |
---|---|
public ToXMLSAXHandler(ContentHandler handler, LexicalHandler lex, String encoding) |
addAttribute | back to summary |
---|---|
public void addAttribute(String uri, String localName, String rawName, String type, String value, boolean XSLAttribute) throws SAXException Overrides com. Implements com. 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.
|
attributeDecl | back to summary |
---|---|
public void attributeDecl(String arg0, String arg1, String arg2, String arg3, String arg4) throws SAXException Implements org. Doc from org. 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.
|
characters | back to summary |
---|---|
public void characters(String chars) throws SAXException Overrides com. Implements com. Doc from com. Receive notification of character data.
|
characters | back to summary |
---|---|
public void characters(char[] ch, int off, int len) throws SAXException Implements org. Doc from org. 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
Your code should not assume that algorithms using
Note that some parsers will report whitespace in element
content using the
|
closeCDATA | back to summary |
---|---|
public void closeCDATA() throws SAXException Overrides com. 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. |
closeStartTag | back to summary |
---|---|
protected void closeStartTag() throws SAXException Overrides com. This method is called when all the data needed for a call to the SAX handler's startElement() method has been gathered. |
comment | back to summary |
---|---|
public void comment(char[] arg0, int arg1, int arg2) throws SAXException Implements org. Doc from org. 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).
|
elementDecl | back to summary |
---|---|
public void elementDecl(String arg0, String arg1) throws SAXException Implements org. Doc from org. 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.
|
endCDATA | back to summary |
---|---|
public void endCDATA() throws SAXException Implements org. Doc from org. Report the end of a CDATA section.
|
endDocument | back to summary |
---|---|
public void endDocument() throws SAXException Implements org. Receives notification of the end of the document.
|
endDTD | back to summary |
---|---|
public void endDTD() throws SAXException Implements org. Doc from org. 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.
|
endElement | back to summary |
---|---|
public void endElement(String namespaceURI, String localName, String qName) throws SAXException Implements org. Doc from org. 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
For information on the names, see startElement.
|
endElement | back to summary |
---|---|
public void endElement(String elemName) throws SAXException Implements com. Doc from com. 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.
|
endPrefixMapping | back to summary |
---|---|
public void endPrefixMapping(String prefix) throws SAXException Implements org. Doc from org. End the scope of a prefix-URI mapping. See
|
ensurePrefixIsDeclared | back to summary |
---|---|
private void ensurePrefixIsDeclared(String ns, String rawName) throws SAXException |
externalEntityDecl | back to summary |
---|---|
public void externalEntityDecl(String arg0, String arg1, String arg2) throws SAXException Implements org. Doc from org. 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.
|
getOutputFormat | back to summary |
---|---|
public Properties getOutputFormat() Implements com. Doc from com. Returns the output format properties for this serializer.
|
getOutputStream | back to summary |
---|---|
public OutputStream getOutputStream() Implements com. Doc from com. Get the output stream where the events will be serialized to.
|
getWriter | back to summary |
---|---|
public Writer getWriter() Implements com. Doc from com. Get the character stream where the events will be serialized to.
|
ignorableWhitespace | back to summary |
---|---|
public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws SAXException Implements org. Doc from org. 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.
|
indent | back to summary |
---|---|
public void indent(int n) throws SAXException Do nothing for SAX. |
internalEntityDecl | back to summary |
---|---|
public void internalEntityDecl(String arg0, String arg1) throws SAXException Implements org. Doc from org. 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.
|
namespaceAfterStartElement | back to summary |
---|---|
public void namespaceAfterStartElement(final String prefix, final String uri) throws SAXException Overrides com. Implements com. 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.
|
popNamespace | back 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. |
processingInstruction | back to summary |
---|---|
public void processingInstruction(String target, String data) throws SAXException Overrides com. Implements org. Doc from com. Do nothing as this is an abstract class. All subclasses will need to define their behavior if it is different.
|
reset | back to summary |
---|---|
public boolean reset() Overrides com. Implements com. 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).
|
resetToXMLSAXHandler | back to summary |
---|---|
private void resetToXMLSAXHandler() Reset all of the fields owned by ToXMLSAXHandler class |
serialize | back to summary |
---|---|
public void serialize(Node node) throws IOException Implements com. Doc from com. Notify that the serializer should take this DOM node as input to be serialized.
|
setDocumentLocator | back to summary |
---|---|
public void setDocumentLocator(Locator arg0) Overrides com. Implements org. Doc from com. Receive an object for locating the origin of SAX document events.
|
setEscaping | back to summary |
---|---|
public boolean setEscaping(boolean escape) throws SAXException Implements com. Doc from com. 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.
|
setOutputFormat | back to summary |
---|---|
public void setOutputFormat(Properties format) Implements com. Doc from com. 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
The non-standard property keys supported are defined in 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.
|
setOutputStream | back to summary |
---|---|
public void setOutputStream(OutputStream output) Implements com. Doc from com. 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 Only one of setWriter() or setOutputStream() should be called.
|
setWriter | back to summary |
---|---|
public void setWriter(Writer writer) Implements com. Doc from com. 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 Only one of setWriter() or setOutputStream() should be called.
|
skippedEntity | back to summary |
---|---|
public void skippedEntity(String arg0) throws SAXException Implements org. Doc from org. 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
|
startCDATA | back to summary |
---|---|
public void startCDATA() throws SAXException Implements org. Doc from org. Report the start of a CDATA section. The contents of the CDATA section will be reported through
the regular
|
startElement | back to summary |
---|---|
public void startElement(String elementNamespaceURI, String elementLocalName, String elementName) throws SAXException Overrides com. Implements com. Start an element in the output document. This might be an XML element
(
|
startElement | back to summary |
---|---|
public void startElement(String elementName) throws SAXException Overrides com. Implements com. Doc from com. An element starts, but attributes are not fully known yet.
|
startElement | back to summary |
---|---|
public void startElement(String namespaceURI, String localName, String name, Attributes atts) throws SAXException Overrides com. Implements org. Doc from com. 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.
|
startEntity | back to summary |
---|---|
public void startEntity(String arg0) throws SAXException Implements org. Doc from org. 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
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
Note that skipped entities will be reported through the
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.
|
startPrefixMapping | back to summary |
---|---|
public void startPrefixMapping(String prefix, String uri) throws SAXException Implements org. Doc from org. 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 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 There should never be start/endPrefixMapping events for the "xml" prefix, since it is predeclared and immutable.
|
startPrefixMapping | back to summary |
---|---|
public boolean startPrefixMapping(String prefix, String uri, boolean shouldFlush) throws SAXException Implements com. Remember the prefix/uri mapping at the current nested element depth.
|