Class Emitter

  • All Implemented Interfaces:
    javax.xml.transform.Result
    Direct Known Subclasses:
    Builder, ContentHandlerProxy, DocumentHandlerProxy, DOMEmitter, ErrorEmitter, ProxyEmitter, StringEmitter, XMLEmitter

    public abstract class Emitter
    extends java.lang.Object
    implements javax.xml.transform.Result
    Emitter: This interface defines methods that must be implemented by components that format SAXON output. There is one emitter for XML, one for HTML, and so on. Additional methods are concerned with setting options and providing a Writer.

    The interface is deliberately designed to be as close as possible to the standard SAX2 ContentHandler interface, however, it allows additional information to be made available.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.xml.sax.Locator locator  
      protected NamePool namePool  
      protected java.util.Properties outputProperties  
      protected java.io.OutputStream outputStream  
      protected java.lang.String systemId  
      protected java.io.Writer writer  
      • Fields inherited from interface javax.xml.transform.Result

        PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING
    • Constructor Summary

      Constructors 
      Constructor Description
      Emitter()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void characters​(char[] chars, int start, int len)
      Output character data
      abstract void comment​(char[] chars, int start, int length)
      Output a comment.
      abstract void endDocument()
      Notify document end
      abstract void endElement​(int nameCode)
      Output an element end tag
      NamePool getNamePool()
      Get the namepool used for this document
      java.util.Properties getOutputProperties()
      Get the output properties
      java.io.OutputStream getOutputStream()
      Get the output stream
      java.lang.String getSystemId()
      Get the System ID
      java.io.Writer getWriter()
      Get the output writer
      static Emitter makeEmitter​(java.lang.String className)
      load a named output emitter or document handler and check it is OK.
      abstract void processingInstruction​(java.lang.String name, java.lang.String data)
      Output a processing instruction
      void setDocumentLocator​(org.xml.sax.Locator locator)
      Set locator, to identify position in the document.
      void setEscaping​(boolean escaping)
      Switch escaping on or off.
      void setNamePool​(NamePool namePool)
      Set the namePool in which all name codes can be found
      void setOutputProperties​(java.util.Properties props)
      Set the output properties
      void setOutputStream​(java.io.OutputStream stream)
      Set the output destination as a byte stream
      void setSystemId​(java.lang.String systemId)
      Set the System ID
      void setUnparsedEntity​(java.lang.String name, java.lang.String uri)
      Set unparsed entity URI Used only when supplying input from a parser.
      void setWriter​(java.io.Writer writer)
      Set the output destination as a character stream
      abstract void startDocument()
      Notify document start
      abstract void startElement​(int nameCode, org.xml.sax.Attributes attributes, int[] namespaces, int nscount)
      Output an element start tag.
      boolean usesWriter()
      Determine whether the Emitter wants a Writer for character output or an OutputStream for binary output
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • systemId

        protected java.lang.String systemId
      • writer

        protected java.io.Writer writer
      • outputStream

        protected java.io.OutputStream outputStream
      • outputProperties

        protected java.util.Properties outputProperties
      • locator

        protected org.xml.sax.Locator locator
    • Constructor Detail

      • Emitter

        public Emitter()
    • Method Detail

      • setNamePool

        public void setNamePool​(NamePool namePool)
        Set the namePool in which all name codes can be found
      • getNamePool

        public NamePool getNamePool()
        Get the namepool used for this document
      • setSystemId

        public void setSystemId​(java.lang.String systemId)
        Set the System ID
        Specified by:
        setSystemId in interface javax.xml.transform.Result
      • getSystemId

        public java.lang.String getSystemId()
        Get the System ID
        Specified by:
        getSystemId in interface javax.xml.transform.Result
      • setOutputProperties

        public void setOutputProperties​(java.util.Properties props)
        Set the output properties
      • getOutputProperties

        public java.util.Properties getOutputProperties()
        Get the output properties
      • usesWriter

        public boolean usesWriter()
        Determine whether the Emitter wants a Writer for character output or an OutputStream for binary output
      • setWriter

        public void setWriter​(java.io.Writer writer)
        Set the output destination as a character stream
      • getWriter

        public java.io.Writer getWriter()
        Get the output writer
      • setOutputStream

        public void setOutputStream​(java.io.OutputStream stream)
        Set the output destination as a byte stream
      • getOutputStream

        public java.io.OutputStream getOutputStream()
        Get the output stream
      • startDocument

        public abstract void startDocument()
                                    throws javax.xml.transform.TransformerException
        Notify document start
        Throws:
        javax.xml.transform.TransformerException
      • endDocument

        public abstract void endDocument()
                                  throws javax.xml.transform.TransformerException
        Notify document end
        Throws:
        javax.xml.transform.TransformerException
      • startElement

        public abstract void startElement​(int nameCode,
                                          org.xml.sax.Attributes attributes,
                                          int[] namespaces,
                                          int nscount)
                                   throws javax.xml.transform.TransformerException
        Output an element start tag.
        Parameters:
        namespaces - Array of namespace codes identifying the namespace prefix/uri pairs associated with this element
        nscount - Number of significant entries within namespaces array
        Throws:
        javax.xml.transform.TransformerException
      • endElement

        public abstract void endElement​(int nameCode)
                                 throws javax.xml.transform.TransformerException
        Output an element end tag
        Throws:
        javax.xml.transform.TransformerException
      • characters

        public abstract void characters​(char[] chars,
                                        int start,
                                        int len)
                                 throws javax.xml.transform.TransformerException
        Output character data
        Throws:
        javax.xml.transform.TransformerException
      • processingInstruction

        public abstract void processingInstruction​(java.lang.String name,
                                                   java.lang.String data)
                                            throws javax.xml.transform.TransformerException
        Output a processing instruction
        Throws:
        javax.xml.transform.TransformerException
      • comment

        public abstract void comment​(char[] chars,
                                     int start,
                                     int length)
                              throws javax.xml.transform.TransformerException
        Output a comment.
        (The method signature is borrowed from the SAX2 LexicalHandler interface)
        Throws:
        javax.xml.transform.TransformerException
      • setEscaping

        public void setEscaping​(boolean escaping)
                         throws javax.xml.transform.TransformerException
        Switch escaping on or off. This is called when the XSLT disable-output-escaping attribute is used to switch escaping on or off. It is also called at the start and end of a CDATA section It is not called for other sections of output (e.g. comments) where escaping is inappropriate.
        Throws:
        javax.xml.transform.TransformerException
      • setDocumentLocator

        public void setDocumentLocator​(org.xml.sax.Locator locator)
        Set locator, to identify position in the document. Used only when supplying input from a parser.
      • setUnparsedEntity

        public void setUnparsedEntity​(java.lang.String name,
                                      java.lang.String uri)
                               throws javax.xml.transform.TransformerException
        Set unparsed entity URI Used only when supplying input from a parser.
        Throws:
        javax.xml.transform.TransformerException
      • makeEmitter

        public static Emitter makeEmitter​(java.lang.String className)
                                   throws javax.xml.transform.TransformerException
        load a named output emitter or document handler and check it is OK.
        Throws:
        javax.xml.transform.TransformerException