Package com.icl.saxon.output
Class StringOutputter
- java.lang.Object
-
- com.icl.saxon.output.Outputter
-
- com.icl.saxon.output.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
Fields Modifier and Type Field Description (package private) java.lang.StringBufferbuffer(package private) javax.xml.transform.ErrorListenererrorListener(package private) intignoreElements
-
Constructor Summary
Constructors Constructor Description StringOutputter(java.lang.StringBuffer buffer)
-
Method Summary
All 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)java.util.PropertiesgetOutputProperties()voidreset()Synchronize the state of the Outputter with that of the underlying EmittervoidsetErrorListener(javax.xml.transform.ErrorListener listener)booleanthereIsAnOpenStartTag()Test whether there is an open start tag.voidwrite(java.lang.String s)Produce literal output.voidwriteAttribute(int nameCode, java.lang.String value, boolean noEscape)Output an attribute value.voidwriteComment(java.lang.String comment)Write a comment.voidwriteContent(char[] chars, int start, int length)Produce text content output.voidwriteContent(java.lang.String s)Produce text content output.voidwriteEndTag(int nameCode)Output an element end tag.voidwriteNamespaceDeclaration(int nscode)Output a namespace declaration.voidwritePI(java.lang.String target, java.lang.String data)Write a processing instruction No-op in this implementationvoidwriteStartTag(int nameCode)Output an element start tag.-
Methods inherited from class com.icl.saxon.output.Outputter
getEmitter, open, setEscaping, writeAttribute
-
-
-
-
Method Detail
-
setErrorListener
public void setErrorListener(javax.xml.transform.ErrorListener listener)
-
reset
public void reset() throws javax.xml.transform.TransformerExceptionDescription copied from class:OutputterSynchronize the state of the Outputter with that of the underlying Emitter
-
getOutputProperties
public java.util.Properties getOutputProperties()
- Specified by:
getOutputPropertiesin classOutputter
-
write
public 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().
-
writeContent
public 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.- Specified by:
writeContentin classOutputter- Parameters:
s- The String to be output- Throws:
javax.xml.transform.TransformerException- for any failure
-
writeContent
public 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.- 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:
javax.xml.transform.TransformerException- for any failure
-
writeStartTag
public void writeStartTag(int nameCode) throws javax.xml.transform.TransformerExceptionOutput an element start tag. With this outputter, this is a recoverable error.- Specified by:
writeStartTagin classOutputter- Parameters:
nameCode- The element name code- Throws:
javax.xml.transform.TransformerException
-
checkAttributePrefix
public 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.- Specified by:
checkAttributePrefixin classOutputter- Throws:
javax.xml.transform.TransformerException
-
writeNamespaceDeclaration
public 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.- Specified by:
writeNamespaceDeclarationin classOutputter- 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 void copyNamespaceNode(int nscode) throws javax.xml.transform.TransformerExceptionCopy a namespace node to the current element node (Rules defined in XSLT 1.0 errata)- Specified by:
copyNamespaceNodein classOutputter- Throws:
javax.xml.transform.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, java.lang.String value, boolean noEscape) throws javax.xml.transform.TransformerExceptionOutput an attribute value.
No-op in this implementation.- 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:
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 void writeEndTag(int nameCode) throws javax.xml.transform.TransformerExceptionOutput an element end tag.- Specified by:
writeEndTagin classOutputter- Parameters:
nameCode- The element name code- Throws:
javax.xml.transform.TransformerException
-
writeComment
public void writeComment(java.lang.String comment) throws javax.xml.transform.TransformerExceptionWrite a comment. No-op in this implementation- Specified by:
writeCommentin classOutputter- Throws:
javax.xml.transform.TransformerException
-
writePI
public void writePI(java.lang.String target, java.lang.String data) throws javax.xml.transform.TransformerExceptionWrite a processing instruction No-op in this implementation
-
-