net.sf.saxon.event

Class ComplexContentOutputter

public final class ComplexContentOutputter extends SequenceReceiver

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.

Author: Michael H. Kay

Constructor Summary
ComplexContentOutputter()
Create a ComplexContentOutputter
Method Summary
voidappend(Item item, int locationId, int copyNamespaces)
Append an arbitrary item (node or atomic value) to the output
voidattribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties)
Output an attribute value.
voidcharacters(CharSequence s, int locationId, int properties)
Produce text content output.
voidclose()
Close the output
voidcomment(CharSequence comment, int locationId, int properties)
Write a comment
booleancontentHasBeenWritten()
Test whether any content has been written to this ComplexContentOutputter
voidendDocument()
Notify the end of a document node
voidendElement()
Output an element end tag.
voidnamespace(int nscode, int properties)
Output a namespace declaration.
voidopen()
Start the output process
voidprocessingInstruction(String target, CharSequence data, int locationId, int properties)
Write a processing instruction
voidsetHostLanguage(int language)
Set the host language
voidsetPipelineConfiguration(PipelineConfiguration pipe)
voidsetReceiver(Receiver receiver)
Set the receiver (to handle the next stage in the pipeline) directly
voidstartContent()
Flush out a pending start tag
voidstartDocument(int properties)
Start of a document node.
voidstartElement(int nameCode, int typeCode, int locationId, int properties)
Output an element start tag.
booleanusesTypeAnnotations()
Ask whether this Receiver (or the downstream pipeline) makes any use of the type annotations supplied on element and attribute events

Constructor Detail

ComplexContentOutputter

public ComplexContentOutputter()
Create a ComplexContentOutputter

Method Detail

append

public void append(Item item, int locationId, int copyNamespaces)
Append an arbitrary item (node or atomic value) to the output

Parameters: item the item to be appended locationId the location of the calling instruction, for diagnostics copyNamespaces if the item is an element node, this indicates whether its namespaces need to be copied. Values are ALL_NAMESPACES, LOCAL_NAMESPACES, NO_NAMESPACES

attribute

public void attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties)
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: nameCode The name of the attribute value The value of the attribute properties 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.

characters

public void characters(CharSequence s, int locationId, int properties)
Produce text content output.
Special characters are escaped using XML/HTML conventions if the output format requires it.

Parameters: s The String to be output

Throws: XPathException for any failure

close

public void close()
Close the output

comment

public void comment(CharSequence comment, int locationId, int properties)
Write a comment

contentHasBeenWritten

public boolean contentHasBeenWritten()
Test whether any content has been written to this ComplexContentOutputter

Returns: true if content has been written

endDocument

public void endDocument()
Notify the end of a document node

endElement

public void endElement()
Output an element end tag.

namespace

public void namespace(int nscode, int properties)
Output a namespace declaration.
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: nscode The namespace code

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.

open

public void open()
Start the output process

processingInstruction

public void processingInstruction(String target, CharSequence data, int locationId, int properties)
Write a processing instruction

setHostLanguage

public void setHostLanguage(int language)
Set the host language

Parameters: language the host language, for example XQUERY

setPipelineConfiguration

public void setPipelineConfiguration(PipelineConfiguration pipe)

setReceiver

public void setReceiver(Receiver receiver)
Set the receiver (to handle the next stage in the pipeline) directly

Parameters: receiver the receiver to handle the next stage in the pipeline

startContent

public void startContent()
Flush out a pending start tag

startDocument

public void startDocument(int properties)
Start of a document node.

startElement

public void startElement(int nameCode, int typeCode, int locationId, int properties)
Output an element start tag.
The actual output of the tag is deferred until all attributes have been output using attribute().

Parameters: nameCode The element name code

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