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.
- Author:
- Michael H. Kay
-
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(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 outputvoidcomment(CharSequence comment, int locationId, int properties) Write a commentbooleanTest whether any content has been written to this ComplexContentOutputtervoidNotify the end of a document nodevoidOutput an element end tag.voidnamespace(int nscode, int properties) Output a namespace declaration.voidopen()Start the output processvoidprocessingInstruction(String target, CharSequence data, int locationId, int properties) Write a processing instructionvoidsetHostLanguage(int language) voidsetPipelineConfiguration(PipelineConfiguration pipelineConfiguration) Set the pipeline configurationvoidsetReceiver(Receiver receiver) Set the receiver (to handle the next stage in the pipeline) directlyvoidFlush out a pending start tagvoidstartDocument(int properties) Start of a document node.voidstartElement(int nameCode, int typeCode, int locationId, int properties) Output an element start tag.Methods inherited from class net.sf.saxon.event.SequenceReceiver
getConfiguration, getNamePool, getPipelineConfiguration, getSystemId, setSystemId, setUnparsedEntity
-
Constructor Details
-
ComplexContentOutputter
public ComplexContentOutputter()
-
-
Method Details
-
setPipelineConfiguration
Description copied from interface:ReceiverSet the pipeline configuration- Specified by:
setPipelineConfigurationin interfaceReceiver- Overrides:
setPipelineConfigurationin classSequenceReceiver
-
setHostLanguage
public void setHostLanguage(int language) -
setReceiver
Set the receiver (to handle the next stage in the pipeline) directly -
contentHasBeenWritten
public boolean contentHasBeenWritten()Test whether any content has been written to this ComplexContentOutputter -
open
Start the output process- Specified by:
openin interfaceReceiver- Overrides:
openin classSequenceReceiver- Throws:
XPathException
-
startDocument
Start of a document node.- Throws:
XPathException
-
endDocument
Notify the end of a document node- Throws:
XPathException
-
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- an integer which can be interpreted using aLocationProviderto return information such as line number and system ID. If no location information is available, the value zero is supplied.properties- Bit significant value. The following bits are defined:- DISABLE_ESCAPING
- Disable escaping for this text node
- USE_CDATA
- Output as a CDATA section
- NO_SPECIAL_CHARACTERS
- Value contains no special characters
- WHITESPACE
- Text is all whitespace
- Throws:
XPathException- for any failure
-
startElement
public void startElement(int nameCode, int typeCode, int locationId, 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:
nameCode- The element name codetypeCode- integer code identifying the element's type within the name pool. The value -1 indicates the default type, xdt:untyped.locationId- an integer which can be interpreted using aLocationProviderto return information such as line number and system ID. If no location information is available, the value zero is supplied.properties- bit-significant properties of the element node. If there are no revelant properties, zero is supplied.- Throws:
XPathException
-
namespace
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 codeproperties- 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: it sets the REJECT_DUPLICATES flag, and this is treated as a hard 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(int nameCode, int typeCode, CharSequence value, int 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:
nameCode- The name of the attributetypeCode- The type of the attribute, as held in the name pool. The additional bit NodeInfo.IS_DTD_TYPE may be set to indicate a DTD-derived type.value- The value of the attributelocationId- an integer which can be interpreted using aLocationProviderto return information such as line number and system ID. If no location information is available, the value zero is supplied.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.
-
endElement
Output an element end tag.- Throws:
XPathException
-
comment
Write a comment- Parameters:
comment- The content of the commentlocationId- an integer which can be interpreted using aLocationProviderto return information such as line number and system ID. If no location information is available, the value zero is supplied.properties- Additional information about the comment. The following bits are defined:- CHECKED
- Comment is known to be legal (e.g. doesn't contain "--")
- Throws:
XPathException
-
processingInstruction
public void processingInstruction(String target, CharSequence data, int 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- an integer which can be interpreted using aLocationProviderto return information such as line number and system ID. If no location information is available, the value zero is supplied.properties- Additional information about the PI. The following bits are defined:- CHECKED
- Data is known to be legal (e.g. doesn't contain "?>")
- Throws:
XPathException
-
append
Append an arbitrary item (node or atomic value) to the output- Overrides:
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- Throws:
XPathException
-
close
Close the output- Throws:
XPathException
-
startContent
Flush out a pending start tag- Throws:
XPathException
-