com.icl.saxon.output

Class StringOutputter

public final class StringOutputter extends Outputter

This class allows output to be generated. It channels output requests to an Emitter which does the actual writing. This is a specialized and simplified version that is used to handle xsl:attribute, xsl:comment, and xsl:processing-instruction.

Author: Michael H. Kay

Field Summary
StringBufferbuffer
ErrorListenererrorListener
intignoreElements
Constructor Summary
StringOutputter(StringBuffer buffer)
Method Summary
intcheckAttributePrefix(int nameCode)
Check that the prefix for an attribute is acceptable, returning a substitute prefix if not.
voidclose()
Close the output
voidcopyNamespaceNode(int nscode)
Copy a namespace node to the current element node (Rules defined in XSLT 1.0 errata)
PropertiesgetOutputProperties()
voidreset()
voidsetErrorListener(ErrorListener listener)
booleanthereIsAnOpenStartTag()
Test whether there is an open start tag.
voidwrite(String s)
Produce literal output.
voidwriteAttribute(int nameCode, String value, boolean noEscape)
Output an attribute value.
voidwriteComment(String comment)
Write a comment.
voidwriteContent(String s)
Produce text content output.
voidwriteContent(char[] chars, int start, int length)
Produce text content output.
voidwriteEndTag(int nameCode)
Output an element end tag.
voidwriteNamespaceDeclaration(int nscode)
Output a namespace declaration.
voidwritePI(String target, String data)
Write a processing instruction No-op in this implementation
voidwriteStartTag(int nameCode)
Output an element start tag.

Field Detail

buffer

StringBuffer buffer

errorListener

ErrorListener errorListener

ignoreElements

int ignoreElements

Constructor Detail

StringOutputter

public StringOutputter(StringBuffer buffer)

Method Detail

checkAttributePrefix

public int checkAttributePrefix(int nameCode)
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.

close

public void close()
Close the output

copyNamespaceNode

public void copyNamespaceNode(int nscode)
Copy a namespace node to the current element node (Rules defined in XSLT 1.0 errata)

getOutputProperties

public Properties getOutputProperties()

reset

public void reset()

setErrorListener

public void setErrorListener(ErrorListener listener)

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.

write

public void write(String s)
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().

writeAttribute

public void writeAttribute(int nameCode, String value, boolean noEscape)
Output an attribute value.
No-op in this implementation.

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

writeComment

public void writeComment(String comment)
Write a comment. No-op in this implementation

writeContent

public void writeContent(String s)
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: TransformerException for any failure

writeContent

public void writeContent(char[] chars, int start, int length)
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: TransformerException for any failure

writeEndTag

public void writeEndTag(int nameCode)
Output an element end tag.

Parameters: nameCode The element name code

writeNamespaceDeclaration

public void writeNamespaceDeclaration(int nscode)
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.

writePI

public void writePI(String target, String data)
Write a processing instruction No-op in this implementation

writeStartTag

public void writeStartTag(int nameCode)
Output an element start tag. With this outputter, this is a recoverable error.

Parameters: nameCode The element name code