com.icl.saxon.output

Class GeneralOutputter


public class GeneralOutputter
extends Outputter

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

Field Summary

Fields inherited from class com.icl.saxon.output.Outputter

emitter

Constructor Summary

GeneralOutputter(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
Properties
getOutputProperties()
Emitter
makeEmitter(Properties props, Result result)
Make an emitter appropriate for a given set of output properties and output destination.
static FileOutputStream
makeFileOutputStream(String baseURI, String fileName, boolean mkdirs)
Create a new FileOutputStream, given a filename and a baseURI
void
reset()
Synchronize the state of the Outputter with that of the underlying Emitter
void
setOutputDestination(Properties props, Result result)
Initialise the outputter for a new output destination, supplying the output format details.
boolean
thereIsAnOpenStartTag()
Test whether there is an open start tag.
static String
urlToFileName(String base)
The following atrocious code is borrowed from Xalan, where it is commented simply: // yuck.
void
write(String s)
Produce literal output.
void
writeAttribute(int nameCode, String value)
Output an attribute value.
void
writeAttribute(int nameCode, String value, boolean noEscape)
Output an attribute value.
void
writeComment(String comment)
Write a comment
void
writeContent(String s)
Produce text content output.
void
writeContent(StringBuffer chars, int start, int len)
Produce text content output.
void
writeContent(char[] chars, int start, int length)
Produce text content output.
void
writeEndTag(int nameCode)
Output an element end tag.
void
writeNamespaceDeclaration(int nscode)
Output a namespace declaration.
void
writePI(String target, String data)
Write a processing instruction
void
writeStartTag(int nameCode)
Output an element start tag.

Methods inherited from class com.icl.saxon.output.Outputter

checkAttributePrefix, close, copyNamespaceNode, getEmitter, getOutputProperties, open, reset, setEscaping, thereIsAnOpenStartTag, write, writeAttribute, writeAttribute, writeComment, writeContent, writeContent, writeEndTag, writeNamespaceDeclaration, writePI, writeStartTag

Constructor Details

GeneralOutputter

public GeneralOutputter(NamePool pool)

Method Details

checkAttributePrefix

public int checkAttributePrefix(int nameCode)
            throws TransformerException
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.
Overrides:
checkAttributePrefix in interface Outputter


close

public void close()
            throws TransformerException
Close the output
Overrides:
close in interface Outputter


copyNamespaceNode

public void copyNamespaceNode(int nscode)
            throws TransformerException
Copy a namespace node to the current element node (Rules defined in XSLT 1.0 errata)
Overrides:
copyNamespaceNode in interface Outputter


flushStartTag

protected void flushStartTag()
            throws TransformerException
Flush out a pending start tag


getOutputProperties

public Properties getOutputProperties()
Overrides:
getOutputProperties in interface Outputter


makeEmitter

public Emitter makeEmitter(Properties props,
                           Result result)
            throws TransformerException
Make an emitter appropriate for a given set of output properties and output destination. Also updates the output properties


makeFileOutputStream

public static FileOutputStream makeFileOutputStream(String baseURI,
                                                    String fileName,
                                                    boolean mkdirs)
            throws TransformerException
Create a new FileOutputStream, given a filename and a baseURI


reset

public void reset()
            throws TransformerException
Synchronize the state of the Outputter with that of the underlying Emitter
Overrides:
reset in interface Outputter


setOutputDestination

public void setOutputDestination(Properties props,
                                 Result result)
            throws TransformerException
Initialise the outputter for a new output destination, supplying the output format details.

Parameters:
result - Details of the new output destination


thereIsAnOpenStartTag

public boolean thereIsAnOpenStartTag()
Test whether there is an open start tag. This determines whether it is possible to write an attribute node at this point.
Overrides:
thereIsAnOpenStartTag in interface Outputter


urlToFileName

public static String urlToFileName(String base)
The following atrocious code is borrowed from Xalan, where it is commented simply: // yuck. The backslash variants added by MHK.


write

public void write(String s)
            throws TransformerException
Produce literal output. This is written as is, without any escaping. The method is provided for Java applications that wish to output literal HTML text. It is not used by the XSL system, which always writes using specific methods such as writeStartTag().
Overrides:
write in interface Outputter


writeAttribute

public void writeAttribute(int nameCode,
                           String value)
            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.
Overrides:
writeAttribute in interface Outputter

Parameters:
nameCode - The name code of the attribute
value - The value of the attribute


writeAttribute

public void writeAttribute(int nameCode,
                           String value,
                           boolean noEscape)
            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.
Before calling this, checkAttributePrefix() should be called to ensure the namespace is OK.
Overrides:
writeAttribute in interface Outputter

Parameters:
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.


writeComment

public void writeComment(String comment)
            throws TransformerException
Write a comment
Overrides:
writeComment in interface Outputter


writeContent

public void writeContent(String s)
            throws TransformerException
Produce text content output.
Special characters are escaped using XML/HTML conventions if the output format requires it.
Overrides:
writeContent in interface Outputter

Parameters:
s - The String to be output


writeContent

public void writeContent(StringBuffer chars,
                         int start,
                         int len)
            throws TransformerException
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


writeContent

public void writeContent(char[] chars,
                         int start,
                         int length)
            throws TransformerException
Produce text content output.
Special characters are escaped using XML/HTML conventions if the output format requires it.
Overrides:
writeContent in interface Outputter

Parameters:
chars - Character array to be output
start - start position of characters to be output
length - number of characters to be output


writeEndTag

public void writeEndTag(int nameCode)
            throws TransformerException
Output an element end tag.
Overrides:
writeEndTag in interface Outputter

Parameters:
nameCode - The element name code


writeNamespaceDeclaration

public void writeNamespaceDeclaration(int nscode)
            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.
Overrides:
writeNamespaceDeclaration in interface Outputter

Parameters:
nscode - The namespace code


writePI

public void writePI(String target,
                    String data)
            throws TransformerException
Write a processing instruction
Overrides:
writePI in interface Outputter


writeStartTag

public void writeStartTag(int nameCode)
            throws TransformerException
Output an element start tag.
The actual output of the tag is deferred until all attributes have been output using writeAttribute().
Overrides:
writeStartTag in interface Outputter

Parameters:
nameCode - The element name code