Package com.icl.saxon.output
Class Outputter
- java.lang.Object
-
- com.icl.saxon.output.Outputter
-
- Direct Known Subclasses:
GeneralOutputter,StringOutputter
public abstract class Outputter extends java.lang.ObjectThis class allows output to be generated. It channels output requests to an Emitter which does the actual writing. This is an abstract class, there are concrete implementions for XML output and text output.- Author:
- Michael H. Kay
-
-
Constructor Summary
Constructors Constructor Description Outputter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract intcheckAttributePrefix(int nameCode)Check that the prefix for an attribute is acceptable, returning a substitute prefix if not.abstract voidclose()Close the outputabstract voidcopyNamespaceNode(int nscode)Copy a namespace node to the current element node (Rules defined in XSLT 1.0 errata)EmittergetEmitter()Get emitter.abstract java.util.PropertiesgetOutputProperties()voidopen()Start the output processabstract voidreset()Synchronize the state of the Outputter with that of the underlying EmittervoidsetEscaping(boolean escaping)Switch escaping (of special characters) on or off.abstract booleanthereIsAnOpenStartTag()Test whether there is an open start tag.abstract voidwrite(java.lang.String s)Produce literal output.voidwriteAttribute(int nameCode, java.lang.String value)Output an attribute value.abstract voidwriteAttribute(int nameCode, java.lang.String value, boolean noEscape)Output an attribute value.abstract voidwriteComment(java.lang.String comment)Write a commentabstract voidwriteContent(char[] chars, int start, int length)Produce text content output.abstract voidwriteContent(java.lang.String s)Produce text content output.abstract voidwriteEndTag(int nameCode)Output an element end tag.abstract voidwriteNamespaceDeclaration(int nscode)Output a namespace declaration.abstract voidwritePI(java.lang.String target, java.lang.String data)Write a processing instructionabstract voidwriteStartTag(int nameCode)Output an element start tag.
-
-
-
Field Detail
-
emitter
protected Emitter emitter
-
-
Method Detail
-
getEmitter
public Emitter getEmitter() throws javax.xml.transform.TransformerException
Get emitter. This is used by xsl:copy-of, a fragment is copied directly to the Emitter rather than going via the Outputter.- Throws:
javax.xml.transform.TransformerException
-
reset
public abstract void reset() throws javax.xml.transform.TransformerExceptionSynchronize the state of the Outputter with that of the underlying Emitter- Throws:
javax.xml.transform.TransformerException
-
getOutputProperties
public abstract java.util.Properties getOutputProperties()
-
setEscaping
public final void setEscaping(boolean escaping) throws javax.xml.transform.TransformerExceptionSwitch escaping (of special characters) on or off.- Parameters:
escaping- : true if special characters are to be escaped, false if not.- Throws:
javax.xml.transform.TransformerException
-
open
public final void open() throws javax.xml.transform.TransformerExceptionStart the output process- Throws:
javax.xml.transform.TransformerException
-
write
public abstract void write(java.lang.String s) throws javax.xml.transform.TransformerExceptionProduce 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().- Throws:
javax.xml.transform.TransformerException
-
writeContent
public abstract void writeContent(java.lang.String s) throws javax.xml.transform.TransformerExceptionProduce 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:
javax.xml.transform.TransformerException- for any failure
-
writeContent
public abstract void writeContent(char[] chars, int start, int length) throws javax.xml.transform.TransformerExceptionProduce text content output.
Special characters are escaped using XML/HTML conventions if the output format requires it.- Parameters:
chars- Character array to be outputstart- start position of characters to be outputlength- number of characters to be output- Throws:
javax.xml.transform.TransformerException- for any failure
-
writeStartTag
public abstract void writeStartTag(int nameCode) throws javax.xml.transform.TransformerExceptionOutput 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- Throws:
javax.xml.transform.TransformerException
-
checkAttributePrefix
public abstract int checkAttributePrefix(int nameCode) throws javax.xml.transform.TransformerExceptionCheck 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.- Throws:
javax.xml.transform.TransformerException
-
writeNamespaceDeclaration
public abstract void writeNamespaceDeclaration(int nscode) throws javax.xml.transform.TransformerExceptionOutput 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:
javax.xml.transform.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.
-
copyNamespaceNode
public abstract void copyNamespaceNode(int nscode) throws javax.xml.transform.TransformerExceptionCopy a namespace node to the current element node (Rules defined in XSLT 1.0 errata)- Throws:
javax.xml.transform.TransformerException
-
thereIsAnOpenStartTag
public abstract boolean thereIsAnOpenStartTag()
Test whether there is an open start tag. This determines whether it is possible to write an attribute node at this point.
-
writeAttribute
public void writeAttribute(int nameCode, java.lang.String value) throws javax.xml.transform.TransformerExceptionOutput 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 attributevalue- The value of the attribute- Throws:
javax.xml.transform.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.
-
writeAttribute
public abstract void writeAttribute(int nameCode, java.lang.String value, boolean noEscape) throws javax.xml.transform.TransformerExceptionOutput 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 attributevalue- The value of the attributenoEscape- True if it's known there are no special characters in the value. If unsure, set this to false.- Throws:
javax.xml.transform.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.
-
writeEndTag
public abstract void writeEndTag(int nameCode) throws javax.xml.transform.TransformerExceptionOutput an element end tag.- Parameters:
nameCode- The element name code- Throws:
javax.xml.transform.TransformerException
-
writeComment
public abstract void writeComment(java.lang.String comment) throws javax.xml.transform.TransformerExceptionWrite a comment- Throws:
javax.xml.transform.TransformerException
-
writePI
public abstract void writePI(java.lang.String target, java.lang.String data) throws javax.xml.transform.TransformerExceptionWrite a processing instruction- Throws:
javax.xml.transform.TransformerException
-
close
public abstract void close() throws javax.xml.transform.TransformerExceptionClose the output- Throws:
javax.xml.transform.TransformerException
-
-