Class ToStream
- All Implemented Interfaces:
DOMSerializer,ExtendedContentHandler,ExtendedLexicalHandler,SerializationHandler,Serializer,ContentHandler,DTDHandler,ErrorHandler,DeclHandler,LexicalHandler
- Direct Known Subclasses:
ToHTMLStream,ToTextStream,ToXMLStream
public abstract class ToStream extends SerializerBase
-
Field Summary
Fields Modifier and Type Field Description static StringCDATA_CONTINUETo insert ]]> in a CDATA section by ending the last CDATA section with ]] and starting the next CDATA section with >static StringCDATA_DELIMITER_CLOSEThe constant "]]>"static StringCDATA_DELIMITER_OPENstatic StringDEFAULT_SAX_SERIALIZERstatic StringEMPTYSTRINGstatic StringENTITY_AMPstatic StringENTITY_CRLFstatic StringENTITY_GTstatic StringENTITY_LTstatic StringENTITY_QUOTprotected booleanm_cdataStartCalledremembers if we are in between the startCDATA() and endCDATA() callbacksprotected org.apache.xml.serializer.CharInfom_charInfoMap that tells which characters should have special treatment, and it provides character to entity name lookup.protected org.apache.xml.serializer.ToStream.BoolStackm_disableOutputEscapingStatesStack to keep track of disabling output escaping.protected booleanm_escapingTaken from XSLTCprotected booleanm_inDoctypeTells if we're in an internal document type subset.protected booleanm_ispreserveState flag to tell if preservation of whitespace is important.protected booleanm_isprevtextState flag that tells if the previous node processed was text, so we can tell if we should preserve whitespace.protected char[]m_lineSepThe system line separator for writing out line breaks.protected intm_lineSepLenThe length of the line seperator, since the write is done one character at a time.protected booleanm_lineSepUseTrue if the the system line separator is to be used.protected org.apache.xml.serializer.ToStream.BoolStackm_preservesStack to keep track of whether or not we need to preserve whitespace.protected booleanm_spaceBeforeCloseAdd space before '/>' for XHTML.static StringXML_PREFIXstatic StringXMLNS_PREFIXstatic StringXMLNS_URIstatic StringXMLVERSION10static StringXMLVERSION11Define the XML version.Fields inherited from class org.apache.xml.serializer.SerializerBase
m_attrBuff, m_attributes, m_CdataElems, m_cdataTagOpen, m_charsBuff, m_doctypePublic, m_doctypeSystem, m_doIndent, m_elemContext, m_indentAmount, m_inEntityRef, m_inExternalDTD, m_mediatype, m_needToCallStartDocument, m_prefixMap, m_shouldNotWriteXMLHeader, m_sourceLocator, m_standaloneWasSpecified, m_StringOfCDATASections, m_tracer, m_version, m_writer, PKG_NAME, PKG_PATHFields inherited from interface org.apache.xml.serializer.ExtendedContentHandler
HTML_ATTREMPTY, HTML_ATTRURL, NO_BAD_CHARS -
Constructor Summary
Constructors Constructor Description ToStream()Default constructor -
Method Summary
Modifier and Type Method Description booleanaddAttributeAlways(String uri, String localName, String rawName, String type, String value, boolean xslAttribute)Adds the given attribute to the set of attributes, even if there is no currently open element.voidaddCdataSectionElements(String URI_and_localNames)Remembers the cdata sections specified in the cdata-section-elements by appending the given cdata section elements to the list.voidattributeDecl(String eName, String aName, String type, String valueDefault, String value)Report an attribute type declaration.protected voidcdata(char[] ch, int start, int length)Receive notification of cdata.voidcharacters(char[] chars, int start, int length)Receive notification of character data.voidcharacters(String s)Receive notification of character data.protected voidcharactersRaw(char[] ch, int start, int length)If available, when the disable-output-escaping attribute is used, output raw text without escaping.protected voidcloseCDATA()This helper method to writes out "]]>" when closing a CDATA section.protected voidcloseStartTag()For the enclosing elements starting tag write out out any attributes followed by ">"voidcomment(char[] ch, int start, int length)Receive notification of an XML comment anywhere in the document.voidelementDecl(String name, String model)Report an element type declaration.voidendCDATA()Report the end of a CDATA section.voidendDTD()Report the end of DTD declarations.voidendElement(String name)Receive notification of the end of an element.voidendElement(String namespaceURI, String localName, String name)Receive notification of the end of an element.voidendNonEscaping()Ends an un-escaping section.voidendPrefixMapping(String prefix)End the scope of a prefix-URI Namespace mapping.protected StringensureAttributesNamespaceIsDeclared(String ns, String localName, String rawName)Makes sure that the namespace URI for the given qualified attribute name is declared.protected booleanescapingNotNeeded(char ch)Tell if this character can be written without escaping.voidexternalEntityDecl(String name, String publicId, String systemId)Report a parsed external entity declaration.protected voidfirePseudoAttributes()To fire off the pseudo characters of attributes, as they currently exist.voidflushPending()This method flushes any pending events, which can be startDocument() closing the opening tag of an element, or closing an open CDATA section.protected voidflushWriter()Flush the formatter's result stream.intgetIndentAmount()Returns the m_indentAmount.PropertiesgetOutputFormat()Returns the output format for this serializer.OutputStreamgetOutputStream()Get the output stream where the events will be serialized to.WritergetWriter()Get the character stream where the events will be serialized to.voidignorableWhitespace(char[] ch, int start, int length)Receive notification of ignorable whitespace in element content.protected voidindent()Indent at the current element nesting depth.protected voidindent(int depth)Might print a newline character and the indentation amount of the given depth.voidinternalEntityDecl(String name, String value)Report an internal entity declaration.voidnotationDecl(String name, String pubID, String sysID)If this method is called, the serializer is used as a DTDHandler, which changes behavior how the serializer handles document entities.protected voidoutputLineSep()Output a system-dependent line break.voidprocessAttributes(Writer writer, int nAttrs)Process the attributes, which means to write out the currently collected attributes to the writer.booleanreset()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).voidserialize(Node node)Serializes the DOM node.voidsetCdataSectionElements(Vector URI_and_localNames)Remembers the cdata sections specified in the cdata-section-elements.voidsetContentHandler(ContentHandler ch)Set the SAX Content handler that the serializer sends its output to.voidsetDTDEntityExpansion(boolean expand)If set to false the serializer does not expand DTD entities, but leaves them as is, the default value is true;voidsetEncoding(String encoding)Sets the character encoding coming from the xsl:output encoding stylesheet attribute.booleansetEscaping(boolean escape)Turns special character escaping on/off.voidsetIndentAmount(int m_indentAmount)Sets the m_indentAmount.booleansetLineSepUse(boolean use_sytem_line_break)Set if the operating systems end-of-line line separator should be used when serializing.voidsetNewLine(char[] eolChars)Sets the end of line characters to be used during serializationvoidsetOutputFormat(Properties format)Specifies an output format for this serializer.voidsetOutputStream(OutputStream output)Specifies an output stream to which the document should be serialized.voidsetTransformer(Transformer transformer)Sets the transformer associated with this serializervoidsetWriter(Writer writer)Specifies a writer to which the document should be serialized.protected booleanshouldIndent()Tell if, based on space preservation constraints and the doIndent property, if an indent should occur.voidskippedEntity(String name)Receive notification of a skipped entity.voidstartCDATA()Report the start of a CDATA section.voidstartDTD(String name, String publicId, String systemId)Report the start of DTD declarations, if any.voidstartElement(String elementName)This method is used to notify of the start of an elementvoidstartElement(String elementNamespaceURI, String elementLocalName, String elementName)Receive notification of the beginning of an element, additional namespace or attribute information can occur before or after this call, that is associated with this element.voidstartElement(String namespaceURI, String localName, String name, Attributes atts)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.voidstartEntity(String name)Report the beginning of an entity.voidstartNonEscaping()Starts an un-escaping section.voidstartPrefixMapping(String prefix, String uri)Begin the scope of a prefix-URI Namespace mapping just before another element is about to start.booleanstartPrefixMapping(String prefix, String uri, boolean shouldFlush)Handle a prefix/uri mapping, which is associated with a startElement() that is soon to follow.voidunparsedEntityDecl(String name, String pubID, String sysID, String notationName)If this method is called, the serializer is used as a DTDHandler, which changes behavior how the serializer handles document entities.voidwriteAttrString(Writer writer, String string, String encoding)Returns the specified string after substituting specials, and UTF-16 surrogates for chracter references&#xnn.protected intwriteUTF16Surrogate(char c, char[] ch, int i, int end)Once a surrogate has been detected, write out the pair of characters if it is in the encoding, or if there is no encoding, otherwise write out an entity reference of the value of the unicode code point of the character represented by the high/low surrogate pair.Methods inherited from class org.apache.xml.serializer.SerializerBase
addAttribute, addAttribute, addAttribute, addAttributes, addXSLAttribute, asContentHandler, asDOM3Serializer, asDOMSerializer, characters, close, comment, documentIsEmpty, endEntity, entityReference, error, fatalError, fireCDATAEvent, fireCharEvent, fireCommentEvent, fireEndDoc, fireEndElem, fireEndEntity, fireEntityReference, fireEscapingEvent, fireStartDoc, fireStartElem, fireStartEntity, getDoctypePublic, getDoctypeSystem, getEncoding, getIndent, getLocalName, getMediaType, getNamespaceMappings, getNamespaceURI, getNamespaceURIFromPrefix, getOmitXMLDeclaration, getOutputProperty, getOutputPropertyDefault, getOutputPropertyNonDefault, getPrefix, getPrefixPart, getStandalone, getTransformer, getVersion, initCDATA, isCdataSection, namespaceAfterStartElement, patchName, setDoctype, setDoctypePublic, setDoctypeSystem, setDocumentLocator, setIndent, setMediaType, setNamespaceMappings, setOmitXMLDeclaration, setOutputProperty, setOutputPropertyDefault, setSourceLocator, setStandalone, setStandaloneInternal, setVersion, startDocument, startDocumentInternal, warningMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
endDocument, processingInstructionMethods inherited from interface org.apache.xml.serializer.ExtendedContentHandler
addUniqueAttribute
-
Field Details
-
m_disableOutputEscapingStates
protected org.apache.xml.serializer.ToStream.BoolStack m_disableOutputEscapingStatesStack to keep track of disabling output escaping. -
m_preserves
protected org.apache.xml.serializer.ToStream.BoolStack m_preservesStack to keep track of whether or not we need to preserve whitespace. Used to push/pop values used for the field m_ispreserve, but m_ispreserve is only relevant if m_doIndent is true. If m_doIndent is false this field has no impact. -
m_ispreserve
protected boolean m_ispreserveState flag to tell if preservation of whitespace is important. Used only in shouldIndent() but only if m_doIndent is true. If m_doIndent is false this flag has no impact. -
m_isprevtext
protected boolean m_isprevtextState flag that tells if the previous node processed was text, so we can tell if we should preserve whitespace. Used in endDocument() and shouldIndent() but only if m_doIndent is true. If m_doIndent is false this flag has no impact. -
m_lineSep
protected char[] m_lineSepThe system line separator for writing out line breaks. The default value is from the system property, but this value can be set through the xsl:output extension attribute xalan:line-separator. -
m_lineSepUse
protected boolean m_lineSepUseTrue if the the system line separator is to be used. -
m_lineSepLen
protected int m_lineSepLenThe length of the line seperator, since the write is done one character at a time. -
m_charInfo
protected org.apache.xml.serializer.CharInfo m_charInfoMap that tells which characters should have special treatment, and it provides character to entity name lookup. -
m_spaceBeforeClose
protected boolean m_spaceBeforeCloseAdd space before '/>' for XHTML. -
m_inDoctype
protected boolean m_inDoctypeTells if we're in an internal document type subset. -
m_cdataStartCalled
protected boolean m_cdataStartCalledremembers if we are in between the startCDATA() and endCDATA() callbacks -
m_escaping
protected boolean m_escapingTaken from XSLTC -
CDATA_CONTINUE
To insert ]]> in a CDATA section by ending the last CDATA section with ]] and starting the next CDATA section with >- See Also:
- Constant Field Values
-
CDATA_DELIMITER_CLOSE
The constant "]]>"- See Also:
- Constant Field Values
-
CDATA_DELIMITER_OPEN
- See Also:
- Constant Field Values
-
EMPTYSTRING
- See Also:
- Constant Field Values
-
ENTITY_AMP
- See Also:
- Constant Field Values
-
ENTITY_CRLF
- See Also:
- Constant Field Values
-
ENTITY_GT
- See Also:
- Constant Field Values
-
ENTITY_LT
- See Also:
- Constant Field Values
-
ENTITY_QUOT
- See Also:
- Constant Field Values
-
XML_PREFIX
- See Also:
- Constant Field Values
-
XMLNS_PREFIX
- See Also:
- Constant Field Values
-
XMLNS_URI
- See Also:
- Constant Field Values
-
DEFAULT_SAX_SERIALIZER
-
XMLVERSION11
Define the XML version.- See Also:
- Constant Field Values
-
XMLVERSION10
- See Also:
- Constant Field Values
-
-
Constructor Details
-
ToStream
public ToStream()Default constructor
-
-
Method Details
-
closeCDATA
This helper method to writes out "]]>" when closing a CDATA section.- Throws:
SAXException
-
serialize
Serializes the DOM node. Throws an exception only if an I/O exception occured while serializing.- Parameters:
node- Node to serialize.- Throws:
IOException- An I/O exception occured while serializing
-
flushWriter
Flush the formatter's result stream.- Throws:
SAXException
-
getOutputStream
Get the output stream where the events will be serialized to.- Returns:
- reference to the result stream, or null of only a writer was set.
-
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 whitespace is removed,and will include the enclosing parentheses.
- Parameters:
name- The element type name.model- The content model as a normalized string.- Throws:
SAXException- The application may raise an exception.
-
internalEntityDecl
Report an internal entity declaration.Only the effective (first) declaration for each entity will be reported.
- Parameters:
name- The name of the entity. If it is a parameter entity, the name will begin with '%'.value- The replacement text of the entity.- Throws:
SAXException- The application may raise an exception.- See Also:
externalEntityDecl(java.lang.String, java.lang.String, java.lang.String),DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
-
outputLineSep
Output a system-dependent line break.- Throws:
SAXExceptionIOException
-
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.- Parameters:
format- The output format to use
-
getOutputFormat
Returns the output format for this serializer.- Returns:
- The output format in use
-
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.- Parameters:
writer- The output writer stream
-
setLineSepUse
public boolean setLineSepUse(boolean use_sytem_line_break)Set if the operating systems end-of-line line separator should be used when serializing. If set false NL character (decimal 10) is left alone, otherwise the new-line will be replaced on output with the systems line separator. For example on UNIX this is NL, while on Windows it is two characters, CR NL, where CR is the carriage-return (decimal 13).- Parameters:
use_sytem_line_break- True if an input NL is replaced with the operating systems end-of-line separator.- Returns:
- The previously set value of the 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.
- Parameters:
output- The output stream
-
setEscaping
public boolean setEscaping(boolean escape)Description copied from interface:SerializationHandlerTurns 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- true if escaping is to be set on.- See Also:
SerializationHandler.setEscaping(boolean)
-
indent
Might print a newline character and the indentation amount of the given depth.- Parameters:
depth- the indentation depth (element nesting depth)- Throws:
SAXException- if an error occurs during writing.IOException
-
indent
Indent at the current element nesting depth.- Throws:
IOException
-
attributeDecl
public void attributeDecl(String eName, String aName, String type, String valueDefault, String value) throws SAXExceptionReport 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", or "NOTATION", or a parenthesized token group with the separator "|" and all whitespace removed.
- Parameters:
eName- The name of the associated element.aName- The name of the attribute.type- A string representing the attribute type.valueDefault- A string representing the attribute default ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies.value- A string representing the attribute's default value, or null if there is none.- Throws:
SAXException- The application may raise an exception.
-
getWriter
Get the character stream where the events will be serialized to.- Returns:
- Reference to the result Writer, or null.
-
externalEntityDecl
Report a parsed external entity declaration.Only the effective (first) declaration for each entity will be reported.
- Parameters:
name- The name of the entity. If it is a parameter entity, the name will begin with '%'.publicId- The declared public identifier of the entity, or null if none was declared.systemId- The declared system identifier of the entity.- Throws:
SAXException- The application may raise an exception.- See Also:
internalEntityDecl(java.lang.String, java.lang.String),DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
-
escapingNotNeeded
protected boolean escapingNotNeeded(char ch)Tell if this character can be written without escaping. -
writeUTF16Surrogate
Once a surrogate has been detected, write out the pair of characters if it is in the encoding, or if there is no encoding, otherwise write out an entity reference of the value of the unicode code point of the character represented by the high/low surrogate pair.An exception is thrown if there is no low surrogate in the pair, because the array ends unexpectely, or if the low char is there but its value is such that it is not a low surrogate.
- Parameters:
c- the first (high) part of the surrogate, which must be confirmed before calling this method.ch- Character array.i- position Where the surrogate was detected.end- The end index of the significant characters.- Returns:
- 0 if the pair of characters was written out as-is, the unicode code point of the character represented by the surrogate pair if an entity reference with that value was written out.
- Throws:
IOExceptionSAXException- if invalid UTF-16 surrogate detected.
-
endNonEscaping
Ends an un-escaping section.- Throws:
SAXException- See Also:
startNonEscaping()
-
startNonEscaping
Starts an un-escaping section. All characters printed within an un- escaping section are printed as is, without escaping special characters into entity references. Only XML and HTML serializers need to support this method.The contents of the un-escaping section will be delivered through the regular characters event.
- Throws:
SAXException
-
cdata
Receive notification of cdata.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.
Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).
- Parameters:
ch- The characters from the XML document.start- The start position in the array.length- The number of characters to read from the array.- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.SAXException- See Also:
ignorableWhitespace(char[], int, int),Locator
-
charactersRaw
If available, when the disable-output-escaping attribute is used, output raw text without escaping.- Parameters:
ch- The characters from the XML document.start- The start position in the array.length- The number of characters to read from the array.- Throws:
SAXException
-
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.
Note that some parsers will report whitespace using the ignorableWhitespace() method rather than this one (validating parsers must do so).
- Parameters:
chars- The characters from the XML document.start- The start position in the array.length- The number of characters to read from the array.- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.SAXException- See Also:
ignorableWhitespace(char[], int, int),Locator
-
characters
Receive notification of character data.- Parameters:
s- The string of characters to process.- Throws:
SAXException
-
startElement
public void startElement(String namespaceURI, String localName, String name, Attributes atts) throws SAXExceptionReceive 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- The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.localName- The local name (without prefix), or the empty string if Namespace processing is not being performed.name- The element type name.atts- The attributes attached to the element, if any.- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.SAXException- See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes),ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String),AttributeList
-
startElement
public void startElement(String elementNamespaceURI, String elementLocalName, String elementName) throws SAXExceptionReceive notification of the beginning of an element, additional namespace or attribute information can occur before or after this call, that is associated with this element.- Parameters:
elementNamespaceURI- The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.elementLocalName- The local name (without prefix), or the empty string if Namespace processing is not being performed.elementName- The element type name.- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.SAXException- See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes),ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String),AttributeList
-
startElement
Description copied from interface:ExtendedContentHandlerThis method is used to notify of the start of an element- Parameters:
elementName- the fully qualified name of the element- Throws:
SAXException
-
processAttributes
Process the attributes, which means to write out the currently collected attributes to the writer. The attributes are not cleared by this method- Parameters:
writer- the writer to write processed attributes to.nAttrs- the number of attributes in m_attributes to be processed- Throws:
IOExceptionSAXException
-
writeAttrString
Returns the specified string after substituting specials, and UTF-16 surrogates for chracter references&#xnn.- Parameters:
string- String to convert to XML format.encoding- CURRENTLY NOT IMPLEMENTED.- Throws:
IOException
-
endElement
Receive notification of the end of an element.- Parameters:
namespaceURI- The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.localName- The local name (without prefix), or the empty string if Namespace processing is not being performed.name- The element type name- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.SAXException
-
endElement
Receive notification of the end of an element.- Parameters:
name- The element type name- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.
-
startPrefixMapping
Begin the scope of a prefix-URI Namespace mapping just before another element is about to start. This call will close any open tags so that the prefix mapping will not apply to the current element, but the up comming child.- Parameters:
prefix- The Namespace prefix being declared.uri- 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)
-
startPrefixMapping
public boolean startPrefixMapping(String prefix, String uri, boolean shouldFlush) throws SAXExceptionHandle a prefix/uri mapping, which is associated with a startElement() that is soon to follow. Need to close any open start tag to make sure than any name space attributes due to this event are associated wih the up comming element, not the current one.- Parameters:
prefix- The Namespace prefix being declared.uri- The Namespace URI the prefix is mapped to.shouldFlush- true if any open tags need to be closed first, this will impact which element the mapping applies to (open parent, or its up comming child)- Returns:
- returns true if the call made a change to the current namespace information, false if it did not change anything, e.g. if the prefix/namespace mapping was already in scope from before.
- Throws:
SAXException- The client may throw an exception during processing.- See Also:
ExtendedContentHandler.startPrefixMapping(java.lang.String, java.lang.String, boolean)
-
comment
Receive notification of 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).- Parameters:
ch- An array holding the characters in the comment.start- The starting position in the array.length- The number of characters to use from the array.- Throws:
SAXException- The application may raise an exception.
-
endCDATA
Report the end of a CDATA section.- Throws:
SAXException- The application may raise an exception.- See Also:
startCDATA()
-
endDTD
Report the end of DTD declarations.- Throws:
SAXException- The application may raise an exception.- See Also:
startDTD(java.lang.String, java.lang.String, java.lang.String)
-
endPrefixMapping
End the scope of a prefix-URI Namespace mapping.- Parameters:
prefix- The prefix that was being mapping.- Throws:
SAXException- The client may throw an exception during processing.- See Also:
ContentHandler.endPrefixMapping(java.lang.String)
-
ignorableWhitespace
Receive notification of ignorable whitespace in element content. Not sure how to get this invoked quite yet.- Parameters:
ch- The characters from the XML document.start- The start position in the array.length- The number of characters to read from the array.- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.SAXException- See Also:
characters(char[], int, int)
-
skippedEntity
Receive notification of a skipped entity.- Parameters:
name- 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)
-
startCDATA
Report the start of a CDATA section.- Throws:
SAXException- The application may raise an exception.- See Also:
endCDATA()
-
startEntity
Report the beginning of an entity. The start and end of the document entity are not reported. The start and end of the external DTD subset are reported using the pseudo-name "[dtd]". All other events must be properly nested within start/end entity events.- Parameters:
name- The name of the entity. If it is a parameter entity, the name will begin with '%'.- Throws:
SAXException- The application may raise an exception.- See Also:
SerializerBase.endEntity(java.lang.String),DeclHandler.internalEntityDecl(java.lang.String, java.lang.String),DeclHandler.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
-
closeStartTag
For the enclosing elements starting tag write out out any attributes followed by ">"- Throws:
SAXException
-
startDTD
Report the start of DTD declarations, if any. Any declarations are assumed to be in the internal subset unless otherwise indicated.- Parameters:
name- The document type name.publicId- The declared public identifier for the external DTD subset, or null if none was declared.systemId- The declared system identifier for the external DTD subset, or null if none was declared.- Throws:
SAXException- The application may raise an exception.- See Also:
endDTD(),startEntity(java.lang.String)
-
getIndentAmount
public int getIndentAmount()Returns the m_indentAmount.- Overrides:
getIndentAmountin classSerializerBase- Returns:
- int
-
setIndentAmount
public void setIndentAmount(int m_indentAmount)Sets the m_indentAmount.- Specified by:
setIndentAmountin interfaceSerializationHandler- Overrides:
setIndentAmountin classSerializerBase- Parameters:
m_indentAmount- The m_indentAmount to set
-
shouldIndent
protected boolean shouldIndent()Tell if, based on space preservation constraints and the doIndent property, if an indent should occur.- Returns:
- True if an indent should occur.
-
setCdataSectionElements
Remembers the cdata sections specified in the cdata-section-elements. The "official way to set URI and localName pairs. This method should be used by both Xalan and XSLTC.- Parameters:
URI_and_localNames- a vector of pairs of Strings (URI/local)
-
ensureAttributesNamespaceIsDeclared
protected String ensureAttributesNamespaceIsDeclared(String ns, String localName, String rawName) throws SAXExceptionMakes sure that the namespace URI for the given qualified attribute name is declared.- Parameters:
ns- the namespace URIrawName- the qualified name- Returns:
- returns null if no action is taken, otherwise it returns the prefix used in declaring the namespace.
- Throws:
SAXException
-
flushPending
This method flushes any pending events, which can be startDocument() closing the opening tag of an element, or closing an open CDATA section.- Throws:
SAXException
-
setContentHandler
Description copied from interface:SerializationHandlerSet the SAX Content handler that the serializer sends its output to. This method only applies to a ToSAXHandler, not to a ToStream serializer.- See Also:
Serializer.asContentHandler(),ToSAXHandler
-
addAttributeAlways
public boolean addAttributeAlways(String uri, String localName, String rawName, String type, String value, boolean xslAttribute)Adds the given attribute to the set of attributes, even if there is no currently open element. This is useful if a SAX startPrefixMapping() should need to add an attribute before the element name is seen. This method is a copy of its super classes method, except that some tracing of events is done. This is so the tracing is only done for stream serializers, not for SAX ones.- Overrides:
addAttributeAlwaysin classSerializerBase- Parameters:
uri- the URI of the attributelocalName- the local name of the attributerawName- the qualified name of the attributetype- the type of the attribute (probably CDATA)value- the value of the attributexslAttribute- true if this attribute is coming from an xsl:attribute element.- Returns:
- true if the attribute value was added, false if the attribute already existed and the value was replaced with the new value.
-
firePseudoAttributes
protected void firePseudoAttributes()To fire off the pseudo characters of attributes, as they currently exist. This method should be called everytime an attribute is added, or when an attribute value is changed, or an element is created. -
setTransformer
Description copied from class:SerializerBaseSets the transformer associated with this serializer- Specified by:
setTransformerin interfaceSerializationHandler- Overrides:
setTransformerin classSerializerBase- Parameters:
transformer- the transformer associated with this serializer.- See Also:
SerializationHandler.setTransformer(Transformer)
-
reset
public boolean 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).- Specified by:
resetin interfaceSerializer- Overrides:
resetin classSerializerBase- Returns:
- true if the class was successfuly reset.
-
setEncoding
Sets the character encoding coming from the xsl:output encoding stylesheet attribute.- Overrides:
setEncodingin classSerializerBase- Parameters:
encoding- the character encoding
-
notationDecl
If this method is called, the serializer is used as a DTDHandler, which changes behavior how the serializer handles document entities.- Specified by:
notationDeclin interfaceDTDHandler- Overrides:
notationDeclin classSerializerBase- Parameters:
name- The notation name.pubID- The notation's public identifier, or null if none was given.sysID- The notation's system identifier, or null if none was given.- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.- See Also:
DTDHandler.notationDecl(java.lang.String, java.lang.String, java.lang.String)
-
unparsedEntityDecl
public void unparsedEntityDecl(String name, String pubID, String sysID, String notationName) throws SAXExceptionIf this method is called, the serializer is used as a DTDHandler, which changes behavior how the serializer handles document entities.- Specified by:
unparsedEntityDeclin interfaceDTDHandler- Overrides:
unparsedEntityDeclin classSerializerBase- Parameters:
name- The unparsed entity's name.pubID- The entity's public identifier, or null if none was given.sysID- The entity's system identifier.notationName- The name of the associated notation.- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.- See Also:
DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
-
setDTDEntityExpansion
public void setDTDEntityExpansion(boolean expand)If set to false the serializer does not expand DTD entities, but leaves them as is, the default value is true;- Specified by:
setDTDEntityExpansionin interfaceSerializationHandler- Overrides:
setDTDEntityExpansionin classSerializerBase- Parameters:
expand- true if DTD entities are to be expanded, false if they are to be left as DTD entity references.
-
setNewLine
public void setNewLine(char[] eolChars)Sets the end of line characters to be used during serialization- Parameters:
eolChars- A character array corresponding to the characters to be used.
-
addCdataSectionElements
Remembers the cdata sections specified in the cdata-section-elements by appending the given cdata section elements to the list. This method can be called multiple times, but once an element is put in the list of cdata section elements it can not be removed. This method should be used by both Xalan and XSLTC.- Parameters:
URI_and_localNames- a whitespace separated list of element names, each element is a URI in curly braces (optional) and a local name. An example of such a parameter is: "{http://company.com}price {myURI2}book chapter"
-