Class 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 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 format
        result - 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.
      • write

        public void write​(String s)
                   throws TransformerException
        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 class Outputter
        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:
        writeContent in class Outputter
        Parameters:
        s - The String to be output
        Throws:
        TransformerException - for any failure
      • writeContent

        public void writeContent​(char[] chars,
                                 int start,
                                 int length)
                          throws TransformerException
        Produce text content output.
        Special characters are escaped using XML/HTML conventions if the output format requires it.
        Specified by:
        writeContent in class Outputter
        Parameters:
        chars - Character array to be output
        start - start position of characters to be output
        length - 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 output
        start - start position of characters to be output
        len - number of characters to be output
        Throws:
        TransformerException - for any failure
      • writeStartTag

        public void writeStartTag​(int nameCode)
                           throws TransformerException
        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 class Outputter
        Parameters:
        nameCode - The element name code
        Throws:
        TransformerException
      • checkAttributePrefix

        public int checkAttributePrefix​(int nameCode)
                                 throws TransformerException
        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 class Outputter
        Throws:
        TransformerException
      • writeNamespaceDeclaration

        public void writeNamespaceDeclaration​(int nscode)
                                       throws TransformerException
        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 class Outputter
        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.
      • 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 class Outputter
      • writeAttribute

        public void writeAttribute​(int nameCode,
                                   String value)
                            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.
        Overrides:
        writeAttribute in class Outputter
        Parameters:
        nameCode - The name code of the attribute
        value - 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 class Outputter
        Parameters:
        name - The name of the attribute
        value - The value of the attribute
        noEscape - 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.