net.sf.saxon.event
Class ComplexContentOutputter

java.lang.Object
  extended bynet.sf.saxon.event.Outputter
      extended bynet.sf.saxon.event.ComplexContentOutputter
All Implemented Interfaces:
Receiver, Result, SequenceReceiver

public class ComplexContentOutputter
extends Outputter

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:
Field Summary
 
Fields inherited from class net.sf.saxon.event.Outputter
previousAtomic
 
Fields inherited from interface javax.xml.transform.Result
PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING
 
Constructor Summary
ComplexContentOutputter()
           
 
Method Summary
 void append(Item item)
          Append an arbitrary item (node or atomic value) to the output
 void attribute(int nameCode, int typeCode, CharSequence value, int properties)
          Output an attribute value.
 void characters(CharSequence s, int properties)
          Produce text content output.
 void comment(CharSequence comment, int properties)
          Write a comment
 void endDocument()
          Close the output
 void endElement()
          Output an element end tag.
 NamePool getNamePool()
          Get the namePool in which all name codes can be found
 String getSystemId()
           
 void namespace(int nscode, int properties)
          Output a namespace declaration.
 void processingInstruction(String target, CharSequence data, int properties)
          Write a processing instruction
 void setNamePool(NamePool pool)
          Set the namePool in which all name codes can be found
 void setReceiver(Receiver receiver)
          Set the receiver (to handle the next stage in the pipeline) directly
 void setSystemId(String systemId)
          Set the System ID of the destination tree
 void startContent()
          Flush out a pending start tag
 void startDocument()
          Start the output process
 void startElement(int nameCode, int typeCode, int properties)
          Output an element start tag.
 
Methods inherited from class net.sf.saxon.event.Outputter
setDocumentLocator, setUnparsedEntity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComplexContentOutputter

public ComplexContentOutputter()
Method Detail

setNamePool

public void setNamePool(NamePool pool)
Description copied from interface: Receiver
Set the namePool in which all name codes can be found

Specified by:
setNamePool in interface Receiver
Overrides:
setNamePool in class Outputter

getNamePool

public NamePool getNamePool()
Description copied from interface: Receiver
Get the namePool in which all name codes can be found

Specified by:
getNamePool in interface Receiver
Overrides:
getNamePool in class Outputter

setSystemId

public void setSystemId(String systemId)
Description copied from interface: Receiver
Set the System ID of the destination tree

Specified by:
setSystemId in interface Receiver
Overrides:
setSystemId in class Outputter

getSystemId

public String getSystemId()
Specified by:
getSystemId in interface Result
Overrides:
getSystemId in class Outputter

setReceiver

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


startDocument

public void startDocument()
                   throws TransformerException
Start the output process

Specified by:
startDocument in interface Receiver
Overrides:
startDocument in class Outputter
Throws:
TransformerException

characters

public void characters(CharSequence s,
                       int properties)
                throws TransformerException
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
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:
TransformerException - for any failure

startElement

public void startElement(int nameCode,
                         int typeCode,
                         int properties)
                  throws TransformerException
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
typeCode - integer code identifying the element's type within the name pool.
Throws:
TransformerException

namespace

public void namespace(int nscode,
                      int properties)
               throws TransformerException
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. Note that unlike SAX2 startPrefixMapping(), this call is made AFTER writing the start tag.

Parameters:
nscode - The namespace code
Throws:
TransformerException - 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 properties)
               throws TransformerException
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
typeCode - The type of the attribute, as held in the name pool
Throws:
TransformerException - 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

public void endElement()
                throws TransformerException
Output an element end tag.

Throws:
TransformerException

comment

public void comment(CharSequence comment,
                    int properties)
             throws TransformerException
Write a comment

Parameters:
comment - The content of the comment
properties - Additional information about the comment. The following bits are defined:
CHECKED
Comment is known to be legal (e.g. doesn't contain "--")
Throws:
TransformerException

processingInstruction

public void processingInstruction(String target,
                                  CharSequence data,
                                  int properties)
                           throws TransformerException
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 instruction
properties - Additional information about the PI. The following bits are defined:
CHECKED
Data is known to be legal (e.g. doesn't contain "?>")
Throws:
TransformerException

append

public void append(Item item)
            throws TransformerException
Append an arbitrary item (node or atomic value) to the output

Throws:
TransformerException

endDocument

public void endDocument()
                 throws TransformerException
Close the output

Throws:
TransformerException

startContent

public void startContent()
                  throws TransformerException
Flush out a pending start tag

Throws:
TransformerException