com.icl.saxon.output
Class Outputter

java.lang.Object
  |
  +--com.icl.saxon.output.Outputter

public class Outputter
extends java.lang.Object

This class allows output to be generated. It channels output requests to an Emitter which does the actual writing.


Constructor Summary
Outputter(NamePool pool)
           
 
Method Summary
 int checkAttributePrefix(int nameCode)
          Check that the prefix for an attribute is acceptable, returning a substitute prefix if not.
 void close()
          Close the output
 void copyNamespaceNode(int nscode)
          Copy a namespace node to the current element node (Rules defined in XSLT 1.0 errata)
protected  void flushStartTag()
          Flush out a pending start tag
 Emitter getEmitter()
          Get emitter.
 OutputDetails getOutputDetails()
           
 void open()
          Start the output process
 void setEmitter(Emitter handler)
          Set the emitter that will deal with this output
 void setEscaping(boolean escaping)
          Switch escaping (of special characters) on or off.
 void setOutputDetails(OutputDetails details)
           
 void write(java.lang.String s)
           
 void writeAttribute(int nameCode, java.lang.String value)
          Output an attribute value.
 void writeAttribute(int nameCode, java.lang.String value, boolean noEscape)
          Output an attribute value.
 void writeComment(java.lang.String comment)
          Write a comment
 void writeContent(char[] chars, int start, int length)
          Produce text content output.
 void writeContent(java.lang.String s)
          Produce text content output.
 void writeContent(java.lang.StringBuffer chars, int start, int len)
          Produce text content output.
 void writeEndTag(int nameCode)
          Output an element end tag.
 void writeNamespaceDeclaration(int nscode)
          Output a namespace declaration.
 void writePI(java.lang.String target, java.lang.String data)
          Write a processing instruction
 void writeStartTag(int nameCode)
          Output an element start tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Outputter

public Outputter(NamePool pool)
Method Detail

setEmitter

public void setEmitter(Emitter handler)
Set the emitter that will deal with this output

getEmitter

public Emitter getEmitter()
                   throws org.xml.sax.SAXException
Get emitter. This is used by xsl:copy-of, a fragment is copied directly to the Emitter rather than going via the Outputter.

setOutputDetails

public void setOutputDetails(OutputDetails details)
                      throws org.xml.sax.SAXException

getOutputDetails

public OutputDetails getOutputDetails()

setEscaping

public void setEscaping(boolean escaping)
                 throws org.xml.sax.SAXException
Switch escaping (of special characters) on or off.
Parameters:
escaping: - true if special characters are to be escaped, false if not.

open

public void open()
          throws org.xml.sax.SAXException
Start the output process

write

public void write(java.lang.String s)
           throws org.xml.sax.SAXException

writeContent

public void writeContent(java.lang.String s)
                  throws org.xml.sax.SAXException
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:
org.xml.sax.SAXException - for any failure

writeContent

public void writeContent(char[] chars,
                         int start,
                         int length)
                  throws org.xml.sax.SAXException
Produce text content output.
Special characters are escaped using XML/HTML conventions if the output format requires it.
Parameters:
chars - Character array to be output
start - start position of characters to be output
length - number of characters to be output
Throws:
org.xml.sax.SAXException - for any failure

writeContent

public void writeContent(java.lang.StringBuffer chars,
                         int start,
                         int len)
                  throws org.xml.sax.SAXException
Produce text content output.
Special characters are escaped using XML/HTML conventions if the output format requires it.
Parameters:
chars - StringBuffer containing to be output
start - start position of characters to be output
len - number of characters to be output
Throws:
org.xml.sax.SAXException - for any failure

writeStartTag

public void writeStartTag(int nameCode)
                   throws org.xml.sax.SAXException
Output an element start tag.
The actual output of the tag is deferred until all attributes have been output using writeAttribute().
Parameters:
nameCode - The element name code

checkAttributePrefix

public int checkAttributePrefix(int nameCode)
                         throws org.xml.sax.SAXException
Check that the prefix for an attribute is acceptable, returning a substitute prefix if not. The prefix is acceptable unless a namespace declaration has been written that assignes this prefix to a different namespace URI. This method also checks that the attribute namespace has been declared, and declares it if not.

writeNamespaceDeclaration

public void writeNamespaceDeclaration(int nscode)
                               throws org.xml.sax.SAXException
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:
org.xml.sax.SAXException - 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.

copyNamespaceNode

public void copyNamespaceNode(int nscode)
                       throws org.xml.sax.SAXException
Copy a namespace node to the current element node (Rules defined in XSLT 1.0 errata)

writeAttribute

public void writeAttribute(int nameCode,
                           java.lang.String value)
                    throws org.xml.sax.SAXException
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 code of the attribute
value - The value of the attribute
Throws:
org.xml.sax.SAXException - 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.

writeAttribute

public void writeAttribute(int nameCode,
                           java.lang.String value,
                           boolean noEscape)
                    throws org.xml.sax.SAXException
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.
Before calling this, checkAttributePrefix() should be called to ensure the namespace is OK.
Parameters:
name - The name of the attribute
value - The value of the attribute
noEscape - True if it's known there are no special characters in the value. If unsure, set this to false.
Throws:
org.xml.sax.SAXException - 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.

writeEndTag

public void writeEndTag(int nameCode)
                 throws org.xml.sax.SAXException
Output an element end tag.
Parameters:
nameCode - The element name code

writeComment

public void writeComment(java.lang.String comment)
                  throws org.xml.sax.SAXException
Write a comment

writePI

public void writePI(java.lang.String target,
                    java.lang.String data)
             throws org.xml.sax.SAXException
Write a processing instruction

close

public void close()
           throws org.xml.sax.SAXException
Close the output

flushStartTag

protected void flushStartTag()
                      throws org.xml.sax.SAXException
Flush out a pending start tag