Package com.icl.saxon.output
Class GeneralOutputter
- java.lang.Object
-
- com.icl.saxon.output.Outputter
-
- com.icl.saxon.output.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.
-
-
Constructor Summary
Constructors Constructor Description GeneralOutputter(NamePool pool)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcheckAttributePrefix(int nameCode)Check that the prefix for an attribute is acceptable, returning a substitute prefix if not.voidclose()Close the outputvoidcopyNamespaceNode(int nscode)Copy a namespace node to the current element node (Rules defined in XSLT 1.0 errata)protected voidflushStartTag()Flush out a pending start tagPropertiesgetOutputProperties()EmittermakeEmitter(Properties props, Result result)Make an emitter appropriate for a given set of output properties and output destination.static FileOutputStreammakeFileOutputStream(String baseURI, String fileName, boolean mkdirs)Create a new FileOutputStream, given a filename and a baseURIvoidreset()Synchronize the state of the Outputter with that of the underlying EmittervoidsetOutputDestination(Properties props, Result result)Initialise the outputter for a new output destination, supplying the output format details.booleanthereIsAnOpenStartTag()Test whether there is an open start tag.static StringurlToFileName(String base)The following atrocious code is borrowed from Xalan, where it is commented simply: // yuck.voidwrite(String s)Produce literal output.voidwriteAttribute(int nameCode, String value)Output an attribute value.voidwriteAttribute(int nameCode, String value, boolean noEscape)Output an attribute value.voidwriteComment(String comment)Write a commentvoidwriteContent(char[] chars, int start, int length)Produce text content output.voidwriteContent(String s)Produce text content output.voidwriteContent(StringBuffer chars, int start, int len)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 instructionvoidwriteStartTag(int nameCode)Output an element start tag.-
Methods inherited from class com.icl.saxon.output.Outputter
getEmitter, open, setEscaping
-
-
-
-
Constructor Detail
-
GeneralOutputter
public GeneralOutputter(NamePool pool)
-
-
Method Detail
-
setOutputDestination
public void setOutputDestination(Properties props, Result result) throws TransformerException
Initialise the outputter for a new output destination, supplying the output format details.- Parameters:
outputProperties- Details of the new output formatresult- Details of the new output destination- Throws:
TransformerException
-
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.
-
makeFileOutputStream
public static FileOutputStream makeFileOutputStream(String baseURI, String fileName, boolean mkdirs) throws TransformerException
Create a new FileOutputStream, given a filename and a baseURI- Throws:
TransformerException
-
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- Throws:
TransformerException
-
reset
public void reset() throws TransformerExceptionDescription copied from class:OutputterSynchronize the state of the Outputter with that of the underlying Emitter- Specified by:
resetin classOutputter- Throws:
TransformerException
-
getOutputProperties
public Properties getOutputProperties()
- Specified by:
getOutputPropertiesin classOutputter
-
write
public void write(String s) throws TransformerException
Description copied from class:OutputterProduce 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().- Specified by:
writein classOutputter- Throws:
TransformerException
-
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.- Specified by:
writeContentin classOutputter- Parameters:
s- The String to be output- Throws:
TransformerException- for any failure
-
writeContent
public void writeContent(char[] chars, int start, int length) throws TransformerExceptionProduce text content output.
Special characters are escaped using XML/HTML conventions if the output format requires it.- Specified by:
writeContentin classOutputter- Parameters:
chars- Character array to be outputstart- start position of characters to be outputlength- number of characters to be output- Throws:
TransformerException- for any failure
-
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 outputstart- start position of characters to be outputlen- number of characters to be output- Throws:
TransformerException- for any failure
-
writeStartTag
public void writeStartTag(int nameCode) throws TransformerExceptionOutput an element start tag.
The actual output of the tag is deferred until all attributes have been output using writeAttribute().- Specified by:
writeStartTagin classOutputter- Parameters:
nameCode- The element name code- Throws:
TransformerException
-
checkAttributePrefix
public int checkAttributePrefix(int nameCode) throws 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.- Specified by:
checkAttributePrefixin classOutputter- Throws:
TransformerException
-
writeNamespaceDeclaration
public void writeNamespaceDeclaration(int nscode) throws 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.- Specified by:
writeNamespaceDeclarationin classOutputter- 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.
-
copyNamespaceNode
public void copyNamespaceNode(int nscode) throws TransformerExceptionCopy a namespace node to the current element node (Rules defined in XSLT 1.0 errata)- Specified by:
copyNamespaceNodein classOutputter- Throws:
TransformerException
-
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.- Specified by:
thereIsAnOpenStartTagin classOutputter
-
writeAttribute
public void writeAttribute(int nameCode, String value) throws 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.- Overrides:
writeAttributein classOutputter- Parameters:
nameCode- The name code of the attributevalue- The value of the attribute- 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.
-
writeAttribute
public void writeAttribute(int nameCode, String value, boolean noEscape) throws 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.- Specified by:
writeAttributein classOutputter- 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:
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 void writeEndTag(int nameCode) throws TransformerExceptionOutput an element end tag.- Specified by:
writeEndTagin classOutputter- Parameters:
nameCode- The element name code- Throws:
TransformerException
-
writeComment
public void writeComment(String comment) throws TransformerException
Write a comment- Specified by:
writeCommentin classOutputter- Throws:
TransformerException
-
writePI
public void writePI(String target, String data) throws TransformerException
Write a processing instruction- Specified by:
writePIin classOutputter- Throws:
TransformerException
-
close
public void close() throws TransformerExceptionClose the output- Specified by:
closein classOutputter- Throws:
TransformerException
-
flushStartTag
protected void flushStartTag() throws TransformerExceptionFlush out a pending start tag- Throws:
TransformerException
-
-