Package com.icl.saxon.output
Class GeneralOutputter
java.lang.Object
com.icl.saxon.output.Outputter
com.icl.saxon.output.GeneralOutputter
This class allows output to be generated. It channels output requests to an
Emitter which does the actual writing.
- Author:
- Michael H. Kay
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
checkAttributePrefix
(int nameCode) Check that the prefix for an attribute is acceptable, returning a substitute prefix if not.void
close()
Close the outputvoid
copyNamespaceNode
(int nscode) Copy a namespace node to the current element node (Rules defined in XSLT 1.0 errata)protected void
Flush out a pending start tagmakeEmitter
(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 baseURIvoid
reset()
Synchronize the state of the Outputter with that of the underlying Emittervoid
setOutputDestination
(Properties props, Result result) Initialise the outputter for a new output destination, supplying the output format details.boolean
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
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 commentvoid
writeContent
(char[] chars, int start, int length) Produce text content output.void
Produce text content output.void
writeContent
(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
Write a processing instructionvoid
writeStartTag
(int nameCode) Output an element start tag.Methods inherited from class com.icl.saxon.output.Outputter
getEmitter, open, setEscaping
-
Field Details
-
charbuffer
char[] charbufferProduce 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().
-
-
Constructor Details
-
GeneralOutputter
-
-
Method Details
-
setOutputDestination
Initialise the outputter for a new output destination, supplying the output format details.- Parameters:
result
- Details of the new output destinationoutputProperties
- Details of the new output format- Throws:
TransformerException
-
urlToFileName
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
Make an emitter appropriate for a given set of output properties and output destination. Also updates the output properties- Throws:
TransformerException
-
reset
Description copied from class:Outputter
Synchronize the state of the Outputter with that of the underlying Emitter- Specified by:
reset
in classOutputter
- Throws:
TransformerException
-
getOutputProperties
- Specified by:
getOutputProperties
in classOutputter
-
write
Description copied from class:Outputter
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().- Specified by:
write
in classOutputter
- Throws:
TransformerException
-
writeContent
Produce text content output.
Special characters are escaped using XML/HTML conventions if the output format requires it.- Specified by:
writeContent
in classOutputter
- Parameters:
s
- The String to be output- Throws:
TransformerException
- for any failure
-
writeContent
Produce text content output.
Special characters are escaped using XML/HTML conventions if the output format requires it.- Specified by:
writeContent
in 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
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
Output an element start tag.
The actual output of the tag is deferred until all attributes have been output using writeAttribute().- Specified by:
writeStartTag
in classOutputter
- Parameters:
nameCode
- The element name code- Throws:
TransformerException
-
checkAttributePrefix
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.- Specified by:
checkAttributePrefix
in classOutputter
- Throws:
TransformerException
-
writeNamespaceDeclaration
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.- Specified by:
writeNamespaceDeclaration
in 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
Copy a namespace node to the current element node (Rules defined in XSLT 1.0 errata)- Specified by:
copyNamespaceNode
in 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:
thereIsAnOpenStartTag
in classOutputter
-
writeAttribute
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 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 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.- Specified by:
writeAttribute
in classOutputter
- Parameters:
value
- The value of the attributenoEscape
- True if it's known there are no special characters in the value. If unsure, set this to false.name
- The name 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.
-
writeEndTag
Output an element end tag.- Specified by:
writeEndTag
in classOutputter
- Parameters:
nameCode
- The element name code- Throws:
TransformerException
-
writeComment
Write a comment- Specified by:
writeComment
in classOutputter
- Throws:
TransformerException
-
writePI
Write a processing instruction- Specified by:
writePI
in classOutputter
- Throws:
TransformerException
-
close
Close the output- Specified by:
close
in classOutputter
- Throws:
TransformerException
-
flushStartTag
Flush out a pending start tag- Throws:
TransformerException
-