Package net.sf.saxon.serialize
Class Emitter
java.lang.Object
net.sf.saxon.event.SequenceReceiver
net.sf.saxon.serialize.Emitter
- All Implemented Interfaces:
Result,Receiver,ReceiverWithOutputProperties
- Direct Known Subclasses:
BinaryEmitter,XMLEmitter
Emitter: This abstract class defines methods that must be implemented by
components that format SAXON output. There is one emitter for XML,
one for HTML, and so on. Additional methods are concerned with
setting options and providing a Writer.
The interface is deliberately designed to be as close as possible to the standard SAX2 ContentHandler interface, however, it allows additional information to be made available.
An Emitter is a Receiver, specifically it is a Receiver that can direct output to a Writer or OutputStream, using serialization properties defined in a Properties object.
The Emitter (from 11.0 onwards) writes to a UnicodeWriter, which may itself bridge to a Writer or OutputStream.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected CharacterSetprotected Propertiesprotected UnicodeWriterFields inherited from class net.sf.saxon.event.SequenceReceiver
pipelineConfiguration, previousAtomic, systemIdFields inherited from interface javax.xml.transform.Result
PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAppend an arbitrary item (node or atomic value) to the outputvoidclose()Notify the end of the event streamGet the output propertiesvoidsetMustClose(boolean mustClose) Set a flag indicating that the unicode writer must be closed after use.voidsetOutputProperties(Properties details) Set output propertiesvoidsetUnicodeWriter(UnicodeWriter unicodeWriter) Set the output destination to which the emitter's output will be writtenvoidsetUnparsedEntity(String name, String uri, String publicId) Set unparsed entity URI.booleanAsk whether this Receiver (or the downstream pipeline) makes any use of the type annotations supplied on element and attribute eventsMethods inherited from class net.sf.saxon.event.SequenceReceiver
append, decompose, flatten, getConfiguration, getErrorCodeForDecomposingFunctionItems, getNamePool, getPipelineConfiguration, getSystemId, handlesAppend, open, setPipelineConfiguration, setSystemIdMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.sf.saxon.event.Receiver
append, characters, comment, endDocument, endElement, getPipelineConfiguration, handlesAppend, open, processingInstruction, setPipelineConfiguration, startDocument, startElementMethods inherited from interface javax.xml.transform.Result
getSystemId, setSystemId
-
Field Details
-
writer
-
outputProperties
-
characterSet
-
allCharactersEncodable
protected boolean allCharactersEncodable
-
-
Constructor Details
-
Emitter
public Emitter()
-
-
Method Details
-
setOutputProperties
Set output properties- Parameters:
details- the output serialization properties- Throws:
XPathException- if an error occurs finding the encoding property
-
getOutputProperties
Get the output properties- Specified by:
getOutputPropertiesin interfaceReceiverWithOutputProperties- Returns:
- the output serialization properties. The returned value will be null if setOutputProperties() has not been called
-
setUnicodeWriter
Set the output destination to which the emitter's output will be written- Parameters:
unicodeWriter- the output destination
-
setMustClose
public void setMustClose(boolean mustClose) Set a flag indicating that the unicode writer must be closed after use. This will generally be true if the writer was created by Saxon, and false if it was supplied by the user- Parameters:
mustClose- true if the unicode writer is to be closed after use.
-
setUnparsedEntity
Set unparsed entity URI. Needed to satisfy the Receiver interface, but not used, because unparsed entities can occur only in input documents, not in output documents.- Specified by:
setUnparsedEntityin interfaceReceiver- Overrides:
setUnparsedEntityin classSequenceReceiver- Parameters:
name- the entity nameuri- the entity system IDpublicId- the entity public ID- Throws:
XPathException- if an error occurs
-
close
Notify the end of the event stream- Specified by:
closein interfaceReceiver- Throws:
XPathException- if an error occurs
-
usesTypeAnnotations
public boolean usesTypeAnnotations()Ask whether this Receiver (or the downstream pipeline) makes any use of the type annotations supplied on element and attribute events- Specified by:
usesTypeAnnotationsin interfaceReceiver- Returns:
- true if the Receiver makes any use of this information. If false, the caller may supply untyped nodes instead of supplying the type annotation (or conversely, it may avoid stripping unwanted type annotations)
-
append
Append an arbitrary item (node or atomic value) to the output- Specified by:
appendin interfaceReceiver- Specified by:
appendin classSequenceReceiver- Parameters:
item- the item to be appendedlocationId- the location of the calling instruction, for diagnosticscopyNamespaces- if the item is an element node, this indicates whether its namespaces need to be copied. Values areReceiverOption.ALL_NAMESPACES; the default (0) means- Throws:
XPathException- if an error occurs
-