Package com.icl.saxon.output
Class Outputter
java.lang.Object
com.icl.saxon.output.Outputter
- Direct Known Subclasses:
GeneralOutputter
,StringOutputter
This 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
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract int
checkAttributePrefix
(int nameCode) Check that the prefix for an attribute is acceptable, returning a substitute prefix if not.abstract void
close()
Close the outputabstract void
copyNamespaceNode
(int nscode) Copy a namespace node to the current element node (Rules defined in XSLT 1.0 errata)Get emitter.abstract Properties
final void
open()
Start the output processabstract void
reset()
Synchronize the state of the Outputter with that of the underlying Emitterfinal void
setEscaping
(boolean escaping) Switch escaping (of special characters) on or off.abstract boolean
Test whether there is an open start tag.abstract void
Produce literal output.void
writeAttribute
(int nameCode, String value) Output an attribute value.abstract void
writeAttribute
(int nameCode, String value, boolean noEscape) Output an attribute value.abstract void
writeComment
(String comment) Write a commentabstract void
writeContent
(char[] chars, int start, int length) Produce text content output.abstract void
Produce text content output.abstract void
writeEndTag
(int nameCode) Output an element end tag.abstract void
writeNamespaceDeclaration
(int nscode) Output a namespace declaration.abstract void
Write a processing instructionabstract void
writeStartTag
(int nameCode) Output an element start tag.
-
Field Details
-
emitter
-
-
Constructor Details
-
Outputter
public Outputter()
-
-
Method Details
-
getEmitter
Get emitter. This is used by xsl:copy-of, a fragment is copied directly to the Emitter rather than going via the Outputter.- Throws:
TransformerException
-
reset
Synchronize the state of the Outputter with that of the underlying Emitter- Throws:
TransformerException
-
getOutputProperties
-
setEscaping
Switch escaping (of special characters) on or off.- Parameters:
escaping
- : true if special characters are to be escaped, false if not.- Throws:
TransformerException
-
open
Start the output process- Throws:
TransformerException
-
write
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().- Throws:
TransformerException
-
writeContent
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
Produce 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:
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().- 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.- 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.- 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)- Throws:
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
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.- 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 abstract 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.- 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.- Parameters:
nameCode
- The element name code- Throws:
TransformerException
-
writeComment
Write a comment- Throws:
TransformerException
-
writePI
Write a processing instruction- Throws:
TransformerException
-
close
Close the output- Throws:
TransformerException
-