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
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
FieldsModifier and TypeFieldDescriptionstatic final String
To insert ]]> in a CDATA section by ending the last CDATA section with ]] and starting the next CDATA section with >static final String
The constant "]]>"static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Define the XML version.Fields inherited from class org.apache.xml.serializer.SerializerBase
PKG_NAME, PKG_PATH
Fields inherited from interface org.apache.xml.serializer.ExtendedContentHandler
HTML_ATTREMPTY, HTML_ATTRURL, NO_BAD_CHARS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttribute
(String uri, String localName, String rawName, String type, String value, boolean xslAttribute) Add an attribute to the current element.void
addUniqueAttribute
(String name, String value, int flags) This method is used to add an attribute to the currently open element.void
CopyFrom
(ToXMLStream xmlListener) Copy properties from another SerializerToXML.void
Receive notification of the end of a document.void
endElement
(String elemName) Receive notification of the end of an element.void
Ends a whitespace preserving section.void
entityReference
(String name) Receive notivication of a entityReference.void
namespaceAfterStartElement
(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.void
processingInstruction
(String target, String data) Receive notification of a processing instruction.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).void
Receive notification of the beginning of a document.void
Starts a whitespace preserving section.Methods inherited from class org.apache.xml.serializer.ToStream
addAttributeAlways, addCdataSectionElements, attributeDecl, characters, characters, comment, elementDecl, endCDATA, endDTD, endElement, endNonEscaping, endPrefixMapping, externalEntityDecl, flushPending, getIndentAmount, getOutputFormat, getOutputStream, getWriter, ignorableWhitespace, internalEntityDecl, notationDecl, processAttributes, serialize, setCdataSectionElements, setContentHandler, setDTDEntityExpansion, setEncoding, setEscaping, setIndentAmount, setLineSepUse, setNewLine, setOutputFormat, setOutputStream, setTransformer, setWriter, skippedEntity, startCDATA, startDTD, startElement, startElement, startElement, startEntity, startNonEscaping, startPrefixMapping, startPrefixMapping, unparsedEntityDecl, writeAttrString
Methods inherited from class org.apache.xml.serializer.SerializerBase
addAttribute, addAttribute, addAttributes, addXSLAttribute, asContentHandler, asDOM3Serializer, asDOMSerializer, characters, close, comment, documentIsEmpty, endEntity, error, fatalError, fireEndEntity, getDoctypePublic, getDoctypeSystem, getEncoding, getIndent, getMediaType, getNamespaceMappings, getNamespaceURI, getNamespaceURIFromPrefix, getOmitXMLDeclaration, getOutputProperty, getOutputPropertyDefault, getOutputPropertyNonDefault, getPrefix, getStandalone, getTransformer, getVersion, setDoctype, setDoctypePublic, setDoctypeSystem, setDocumentLocator, setIndent, setMediaType, setNamespaceMappings, setOmitXMLDeclaration, setOutputProperty, setOutputPropertyDefault, setSourceLocator, setStandalone, setVersion, startDocument, warning
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
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:
-
CDATA_DELIMITER_CLOSE
The constant "]]>"- See Also:
-
CDATA_DELIMITER_OPEN
- See Also:
-
EMPTYSTRING
- See Also:
-
ENTITY_AMP
- See Also:
-
ENTITY_CRLF
- See Also:
-
ENTITY_GT
- See Also:
-
ENTITY_LT
- See Also:
-
ENTITY_QUOT
- See Also:
-
XML_PREFIX
- See Also:
-
XMLNS_PREFIX
- See Also:
-
XMLNS_URI
- See Also:
-
DEFAULT_SAX_SERIALIZER
-
XMLVERSION11
Define the XML version.- See Also:
-
XMLVERSION10
- See Also:
-
-
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.- 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
-
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:
-
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:
entityReference
in interfaceExtendedContentHandler
- Overrides:
entityReference
in 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 SAXException Add an attribute to the current element.- Specified by:
addAttribute
in interfaceExtendedContentHandler
- Overrides:
addAttribute
in 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:
-
endElement
Description copied from class:ToStream
Receive notification of the end of an element.- Specified by:
endElement
in interfaceExtendedContentHandler
- Overrides:
endElement
in classToStream
- Parameters:
elemName
- The element type name- Throws:
SAXException
- Any SAX exception, possibly wrapping another exception.- See Also:
-
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:
namespaceAfterStartElement
in interfaceExtendedContentHandler
- Overrides:
namespaceAfterStartElement
in classSerializerBase
- Parameters:
prefix
- the URI of the namespaceuri
- the prefix associated with the given URI.- Throws:
SAXException
- See Also:
-
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:
reset
in interfaceSerializer
- Overrides:
reset
in classToStream
- Returns:
- true if the class was successfuly reset.
-