Package net.sf.saxon.event
Class ComplexContentOutputter
java.lang.Object
net.sf.saxon.event.SequenceReceiver
net.sf.saxon.event.ComplexContentOutputter
This class is used for generating complex content, that is, the content of an
element or document node. It enforces the rules on the order of events within
complex content (attributes and namespaces must come first), and it implements
part of the namespace fixup rules, in particular, it ensures that there is a
namespace node for the namespace used in the element name and in each attribute
name.
The same ComplexContentOutputter may be used for generating an entire XML document; it is not necessary to create a new outputter for each element node.
From Saxon 9.9, the ComplexContentOutputter does not combine top-level events. Unless nested within a startDocument/endDocument or startElement/endElement pair, items such as atomic values, text nodes, attribute nodes, maps and arrays are passed through unchanged to the output. It is typically the responsibility of the Destination object to decide how to combine top-level events (whether to build a single document, whether to insert item separators, etc).
-
Field Summary
Fields 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 outputvoidattribute(NodeName attName, SimpleType typeCode, CharSequence value, Location locationId, int properties) Output an attribute value.voidbulkCopyElementNode(TinyElementImpl elementNode, int copyOptions) voidcharacters(CharSequence s, Location locationId, int properties) Produce text content output.voidclose()Close the outputvoidcomment(CharSequence comment, Location locationId, int properties) Write a commentvoidNotify the end of a document nodevoidOutput an element end tag.Get the next receiver in the processing pipelinevoidgraftElementNode(TinyElementImpl elementNode, int copyOptions) booleanbooleanstatic ReceivermakeComplexContentReceiver(Receiver receiver, ParseOptions options) Static factory method to create an push pipeline containing a ComplexContentOutputtervoidnamespace(NamespaceBindingSet nsBindings, int properties) Output one or more namespace declarations.voidopen()Start the output processvoidprocessingInstruction(String target, CharSequence data, Location locationId, int properties) Write a processing instructionvoidsetHostLanguage(int language) Set the host languagevoidSet the pipeline configurationvoidsetReceiver(Receiver receiver) Set the receiver (to handle the next stage in the pipeline) directlyvoidsetSystemId(String systemId) Set the system IDvoidsetUnparsedEntity(String name, String systemID, String publicID) Notify an unparsed entity URI.voidFlush out a pending start tagvoidstartDocument(int properties) Start of a document node.voidstartElement(NodeName elemName, SchemaType typeCode, Location location, int properties) Output an element start tag.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
-
Constructor Details
-
ComplexContentOutputter
Create a ComplexContentOutputter- Parameters:
next- the next receiver in the pipeline
-
-
Method Details
-
makeComplexContentReceiver
Static factory method to create an push pipeline containing a ComplexContentOutputter- Parameters:
receiver- the destination to which the constructed complex content will be writtenoptions- options for validating the output stream; may be null
-
setPipelineConfiguration
Description copied from interface:ReceiverSet the pipeline configuration- Specified by:
setPipelineConfigurationin interfaceReceiver- Overrides:
setPipelineConfigurationin classSequenceReceiver- Parameters:
pipe- the pipeline configuration
-
setSystemId
Description copied from class:SequenceReceiverSet the system ID- Specified by:
setSystemIdin interfaceReceiver- Specified by:
setSystemIdin interfaceResult- Overrides:
setSystemIdin classSequenceReceiver- Parameters:
systemId- the URI used to identify the tree being passed across this interface
-
setHostLanguage
public void setHostLanguage(int language) Set the host language- Parameters:
language- the host language, for exampleConfiguration.XQUERY
-
setReceiver
Set the receiver (to handle the next stage in the pipeline) directly- Parameters:
receiver- the receiver to handle the next stage in the pipeline
-
getReceiver
Get the next receiver in the processing pipeline- Returns:
- the receiver which this ComplexContentOutputter writes to
-
open
Start the output process- Specified by:
openin interfaceReceiver- Overrides:
openin classSequenceReceiver- Throws:
XPathException- if an error occurs
-
startDocument
Start of a document node.- Parameters:
properties- bit-significant integer indicating properties of the document node. The definitions of the bits are in classReceiverOptions- Throws:
XPathException- if an error occurs
-
endDocument
Notify the end of a document node- Throws:
XPathException- if an error occurs
-
setUnparsedEntity
Notify an unparsed entity URI.- Specified by:
setUnparsedEntityin interfaceReceiver- Overrides:
setUnparsedEntityin classSequenceReceiver- Parameters:
name- The name of the unparsed entitysystemID- The system identifier of the unparsed entitypublicID- The public identifier of the unparsed entity- Throws:
XPathException- if an error occurs
-
characters
Produce text content output.
Special characters are escaped using XML/HTML conventions if the output format requires it.- Parameters:
s- The String to be outputlocationId- the location of the node in the source, or of the instruction that created itproperties- Bit significant value. The following bits are defined:- DISABLE_ESCAPING
- Disable escaping for this text node
- USE_CDATA
- Output as a CDATA section
- Throws:
XPathException- for any failure
-
startElement
public void startElement(NodeName elemName, SchemaType typeCode, Location location, int properties) throws XPathException Output an element start tag.
The actual output of the tag is deferred until all attributes have been output using attribute().- Parameters:
elemName- The element namelocation- the location of the element node (or the instruction that created it)typeCode- the type annotation of the element.properties- bit-significant properties of the element node. If there are no revelant properties, zero is supplied. The definitions of the bits are in classReceiverOptions- Throws:
XPathException- if an error occurs
-
namespace
Output one or more namespace declarations.
This is added to a list of pending namespaces for the current start tag. If there is already another declaration of the same prefix, this one is ignored, unless the REJECT_DUPLICATES flag is set, in which case this is an error. Note that unlike SAX2 startPrefixMapping(), this call is made AFTER writing the start tag.- Parameters:
nsBindings- The namespace bindingsproperties- The most important property is REJECT_DUPLICATES. If this property is set, the namespace declaration will be rejected if it conflicts with a previous declaration of the same prefix. If the property is not set, the namespace declaration will be ignored if it conflicts with a previous declaration. This reflects the fact that when copying a tree, namespaces for child elements are emitted before the namespaces of their parent element. Unfortunately this conflicts with the XSLT rule for complex content construction, where the recovery action in the event of conflicts is to take the namespace that comes last. XSLT therefore doesn't recover from this error:- Throws:
XPathException- if there is no start tag to write to (created using writeStartTag), or if character content has been written since the start tag was written.
-
attribute
public void attribute(NodeName attName, SimpleType typeCode, CharSequence value, Location locationId, int properties) throws XPathException Output an attribute value.
This is added to a list of pending attributes for the current start tag, overwriting any previous attribute with the same name.
This method should NOT be used to output namespace declarations.- Parameters:
attName- The name of the attributevalue- The value of the attributelocationId- the location of the node in the source, or of the instruction that created itproperties- Bit fields containing properties of the attribute to be written @throws XPathException if there is no start tag to write to (created using writeStartTag), or if character content has been written since the start tag was written.typeCode- The type annotation of the attribute- Throws:
XPathException- if an error occurs
-
endElement
Output an element end tag.- Throws:
XPathException- if an error occurs
-
comment
public void comment(CharSequence comment, Location locationId, int properties) throws XPathException Write a comment- Parameters:
comment- The content of the commentlocationId- provides information such as line number and system ID.properties- Additional information about the comment.- Throws:
XPathException- if an error occurs
-
processingInstruction
public void processingInstruction(String target, CharSequence data, Location locationId, int properties) throws XPathException Write a processing instruction- Parameters:
target- The PI name. This must be a legal name (it will not be checked).data- The data portion of the processing instructionlocationId- provides information such as line number and system ID.properties- Additional information about the PI.- Throws:
XPathException- if an error occurs
-
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 areReceiverOptions.ALL_NAMESPACES,ReceiverOptions.LOCAL_NAMESPACES; the default (0) means no namespaces- Throws:
XPathException
-
close
Close the output- Throws:
XPathException- if an error occurs
-
startContent
Flush out a pending start tag- 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- 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
-
isReadyForGrafting
public boolean isReadyForGrafting() -
graftElementNode
- Throws:
XPathException
-
isReadyForBulkCopy
public boolean isReadyForBulkCopy() -
bulkCopyElementNode
- Throws:
XPathException
-