Package org.apache.xml.serializer
Class ToXMLStream
java.lang.Object
org.apache.xml.serializer.SerializerBase
org.apache.xml.serializer.ToStream
org.apache.xml.serializer.ToXMLStream
- All Implemented Interfaces:
DOMSerializer,ExtendedContentHandler,ExtendedLexicalHandler,SerializationHandler,Serializer,ContentHandler,DTDHandler,ErrorHandler,DeclHandler,LexicalHandler
public class ToXMLStream extends ToStream
This class converts SAX or SAX-like calls to a
serialized xml document. The xsl:output method is "xml".
This class is used explicitly in code generated by XSLTC,
so it is "public", but it should
be viewed as internal or package private, this is not an API.
-
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_QUOTstatic StringXML_PREFIXstatic StringXMLNS_PREFIXstatic StringXMLNS_URIstatic StringXMLVERSION10static StringXMLVERSION11Define the XML version.Fields inherited from class org.apache.xml.serializer.ToStream
m_cdataStartCalled, m_charInfo, m_disableOutputEscapingStates, m_escaping, m_inDoctype, m_ispreserve, m_isprevtext, m_lineSep, m_lineSepLen, m_lineSepUse, m_preserves, m_spaceBeforeCloseFields 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 ToXMLStream()Default constructor. -
Method Summary
Modifier and Type Method Description voidaddAttribute(String uri, String localName, String rawName, String type, String value, boolean xslAttribute)Add an attribute to the current element.voidaddUniqueAttribute(String name, String value, int flags)This method is used to add an attribute to the currently open element.voidCopyFrom(ToXMLStream xmlListener)Copy properties from another SerializerToXML.voidendDocument()Receive notification of the end of a document.voidendElement(String elemName)Receive notification of the end of an element.voidendPreserving()Ends a whitespace preserving section.voidentityReference(String name)Receive notivication of a entityReference.voidnamespaceAfterStartElement(String prefix, String uri)This method is used to notify the serializer of a namespace mapping (or node) that applies to the current element whose startElement() call has already been seen.voidprocessingInstruction(String target, String data)Receive notification of a processing instruction.protected booleanpushNamespace(String prefix, String uri)From XSLTC Declare a prefix to point to a namespace URI.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).voidstartDocumentInternal()Receive notification of the beginning of a document.voidstartPreserving()Starts a whitespace preserving section.Methods inherited from class org.apache.xml.serializer.ToStream
addAttributeAlways, addCdataSectionElements, attributeDecl, cdata, characters, characters, charactersRaw, closeCDATA, closeStartTag, comment, elementDecl, endCDATA, endDTD, endElement, endNonEscaping, endPrefixMapping, ensureAttributesNamespaceIsDeclared, escapingNotNeeded, externalEntityDecl, firePseudoAttributes, flushPending, flushWriter, getIndentAmount, getOutputFormat, getOutputStream, getWriter, ignorableWhitespace, indent, indent, internalEntityDecl, notationDecl, outputLineSep, processAttributes, serialize, setCdataSectionElements, setContentHandler, setDTDEntityExpansion, setEncoding, setEscaping, setIndentAmount, setLineSepUse, setNewLine, setOutputFormat, setOutputStream, setTransformer, setWriter, shouldIndent, skippedEntity, startCDATA, startDTD, startElement, startElement, startElement, startEntity, startNonEscaping, startPrefixMapping, startPrefixMapping, unparsedEntityDecl, writeAttrString, writeUTF16SurrogateMethods inherited from class org.apache.xml.serializer.SerializerBase
addAttribute, addAttribute, addAttributes, addXSLAttribute, asContentHandler, asDOM3Serializer, asDOMSerializer, characters, close, comment, documentIsEmpty, endEntity, 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, patchName, setDoctype, setDoctypePublic, setDoctypeSystem, setDocumentLocator, setIndent, setMediaType, setNamespaceMappings, setOmitXMLDeclaration, setOutputProperty, setOutputPropertyDefault, setSourceLocator, setStandalone, setStandaloneInternal, setVersion, startDocument, warning
-
Field Details
-
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
-
ToXMLStream
public ToXMLStream()Default constructor.
-
-
Method Details
-
CopyFrom
Copy properties from another SerializerToXML.- Parameters:
xmlListener- non-null reference to a SerializerToXML object.
-
startDocumentInternal
Receive notification of the beginning of a document.- Overrides:
startDocumentInternalin classSerializerBase- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.SAXException
-
endDocument
Receive notification of the end of a document.- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.SAXException- See Also:
ContentHandler.startDocument()
-
startPreserving
Starts a whitespace preserving section. All characters printed within a preserving section are printed without indentation and without consolidating multiple spaces. This is equivalent to the xml:space="preserve" attribute. Only XML and HTML serializers need to support this method.The contents of the whitespace preserving section will be delivered through the regular characters event.
- Throws:
SAXException
-
endPreserving
Ends a whitespace preserving section.- Throws:
SAXException- See Also:
startPreserving()
-
processingInstruction
Receive notification of a processing instruction.- Parameters:
target- The processing instruction target.data- The processing instruction data, or null if none was supplied.- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.SAXException
-
entityReference
Receive notivication of a entityReference.- Specified by:
entityReferencein interfaceExtendedContentHandler- Overrides:
entityReferencein classSerializerBase- Parameters:
name- The name of the entity.- Throws:
SAXException
-
addUniqueAttribute
This method is used to add an attribute to the currently open element. The caller has guaranted that this attribute is unique, which means that it not been seen before and will not be seen again.- Parameters:
name- the qualified name of the attributevalue- the value of the attribute which can contain only ASCII printable characters characters in the range 32 to 127 inclusive.flags- the bit values of this integer give optimization information.- Throws:
SAXException
-
addAttribute
public void addAttribute(String uri, String localName, String rawName, String type, String value, boolean xslAttribute) throws SAXExceptionAdd an attribute to the current element.- Specified by:
addAttributein interfaceExtendedContentHandler- Overrides:
addAttributein classSerializerBase- Parameters:
uri- the URI associated with the element namelocalName- local part of the attribute namerawName- prefix:localNametype-value- the value of the attributexslAttribute- true if this attribute is from an xsl:attribute, false if declared within the elements opening tag.- Throws:
SAXException- See Also:
ExtendedContentHandler.addAttribute(String, String, String, String, String)
-
endElement
Description copied from class:ToStreamReceive notification of the end of an element.- Specified by:
endElementin interfaceExtendedContentHandler- Overrides:
endElementin classToStream- Parameters:
elemName- The element type name- Throws:
SAXException- Any SAX exception, possibly wrapping another exception.- See Also:
ExtendedContentHandler.endElement(String)
-
namespaceAfterStartElement
This method is used to notify the serializer of a namespace mapping (or node) that applies to the current element whose startElement() call has already been seen. The official SAX startPrefixMapping(prefix,uri) is to define a mapping for a child element that is soon to be seen with a startElement() call. The official SAX call does not apply to the current element, hence the reason for this method.- Specified by:
namespaceAfterStartElementin interfaceExtendedContentHandler- Overrides:
namespaceAfterStartElementin classSerializerBase- Parameters:
prefix- the URI of the namespaceuri- the prefix associated with the given URI.- Throws:
SAXException- See Also:
ExtendedContentHandler.namespaceAfterStartElement(String, String)
-
pushNamespace
From XSLTC Declare a prefix to point to a namespace URI. Inform SAX handler if this is a new prefix mapping. -
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 classToStream- Returns:
- true if the class was successfuly reset.
-