com.icl.saxon.output

## Class XMLEmitter

- java.lang.Object
- - com.icl.saxon.output.Emitter
  - - com.icl.saxon.output.XMLEmitter

- All Implemented Interfaces:
    javax.xml.transform.Result
  Direct Known Subclasses:
    HTMLEmitter, MessageEmitter, TEXTEmitter, XHTMLEmitter

      public class XMLEmitter
      extends Emitter

  XMLEmitter is an Emitter that generates XML output to a specified destination.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected CharacterSet` | `characterSet`
    `protected boolean` | `declarationIsWritten`
    `protected boolean` | `empty`
    `protected boolean` | `escaping`
    `protected java.lang.String` | `lastDisplayName`
    `protected int` | `lastNameCode`
    `protected java.lang.String` | `lastPrefix`
    `protected java.lang.String` | `lastURI`
    `protected boolean` | `openStartTag`
    `protected boolean` | `preferHex`

    - ### Fields inherited from class com.icl.saxon.output.Emitter

      `locator, namePool, outputProperties, outputStream, systemId, writer`

    - ### Fields inherited from interface javax.xml.transform.Result

      `PI_DISABLE_OUTPUT_ESCAPING, PI_ENABLE_OUTPUT_ESCAPING`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XMLEmitter()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `characters(char[] ch, int start, int length)` Character data.
    `protected void` | `closeStartTag(int nameCode, boolean emptyTag)`
    `void` | `comment(char[] ch, int start, int length)` Handle a comment.
    `protected java.lang.String` | `emptyElementTagCloser(int nameCode)` Close an empty element tag.
    `void` | `endDocument()` End of the document.
    `void` | `endElement(int nameCode)` End of an element.
    `protected void` | `outputCharacterReference(int charval)`
    `void` | `processingInstruction(java.lang.String target, java.lang.String data)` Handle a processing instruction.
    `void` | `setDocumentLocator(org.xml.sax.Locator locator)` Set Document Locator.
    `void` | `setEscaping(boolean escaping)` Set escaping on or off
    `void` | `setOutputProperties(java.util.Properties details)` Set output properties
    `void` | `setResult(javax.xml.transform.Result result)` Set the result destination
    `void` | `setUnparsedEntity(java.lang.String name, java.lang.String uri)` Set the URI for an unparsed entity in the document.
    `void` | `startDocument()` Start of the document.
    `void` | `startElement(int nameCode, org.xml.sax.Attributes attributes, int[] namespaces, int nscount)` Start of an element.
    `protected boolean` | `testCharacters(char[] array, int start, int len)`
    `protected void` | `testCharacters(java.lang.String name)` Test that all characters in a name are supported in the target encoding
    `protected void` | `writeAttribute(int elCode, java.lang.String attname, java.lang.String type, java.lang.String value)`
    `void` | `writeDeclaration()` Output the XML declaration
    `protected void` | `writeDocType(java.lang.String type, java.lang.String systemId, java.lang.String publicId)`
    `protected void` | `writeEscape(char[] ch, int start, int length, boolean inAttribute)` Write contents of array to current writer, after escaping special characters

    - ### Methods inherited from class com.icl.saxon.output.Emitter

      `getNamePool, getOutputProperties, getOutputStream, getSystemId, getWriter, makeEmitter, setNamePool, setOutputStream, setSystemId, setWriter, usesWriter`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### characterSet

          protected CharacterSet characterSet

    - #### empty

          protected boolean empty

    - #### escaping

          protected boolean escaping

    - #### openStartTag

          protected boolean openStartTag

    - #### declarationIsWritten

          protected boolean declarationIsWritten

    - #### preferHex

          protected boolean preferHex

    - #### lastNameCode

          protected int lastNameCode

    - #### lastDisplayName

          protected java.lang.String lastDisplayName

    - #### lastPrefix

          protected java.lang.String lastPrefix

    - #### lastURI

          protected java.lang.String lastURI

  - ### Constructor Detail

    - #### XMLEmitter

          public XMLEmitter()

  - ### Method Detail

    - #### setDocumentLocator

          public void setDocumentLocator(org.xml.sax.Locator locator)

      Set Document Locator. Provided merely to satisfy the interface.
      Overrides:
        `setDocumentLocator` in class `Emitter`

    - #### startDocument

          public void startDocument()
                             throws javax.xml.transform.TransformerException

      Start of the document. Make the writer and write the XML declaration.
      Specified by:
        `startDocument` in class `Emitter`
      Throws:
        `javax.xml.transform.TransformerException`

    - #### writeDeclaration

          public void writeDeclaration()
                                throws javax.xml.transform.TransformerException

      Output the XML declaration
      Throws:
        `javax.xml.transform.TransformerException`

    - #### writeDocType

          protected void writeDocType(java.lang.String type,
                          java.lang.String systemId,
                          java.lang.String publicId)
                               throws javax.xml.transform.TransformerException

      Throws:
        `javax.xml.transform.TransformerException`

    - #### endDocument

          public void endDocument()
                           throws javax.xml.transform.TransformerException

      End of the document. Close the output stream.
      Specified by:
        `endDocument` in class `Emitter`
      Throws:
        `javax.xml.transform.TransformerException`

    - #### startElement

          public void startElement(int nameCode,
                          org.xml.sax.Attributes attributes,
                          int[] namespaces,
                          int nscount)
                            throws javax.xml.transform.TransformerException

      Start of an element. Output the start tag, escaping special characters.
      Specified by:
        `startElement` in class `Emitter`
        `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`

    - #### closeStartTag

          protected void closeStartTag(int nameCode,
                           boolean emptyTag)
                                throws javax.xml.transform.TransformerException

      Throws:
        `javax.xml.transform.TransformerException`

    - #### emptyElementTagCloser

          protected java.lang.String emptyElementTagCloser(int nameCode)

      Close an empty element tag. (This is overridden in XHTMLEmitter).

    - #### writeAttribute

          protected void writeAttribute(int elCode,
                            java.lang.String attname,
                            java.lang.String type,
                            java.lang.String value)
                                 throws javax.xml.transform.TransformerException

      Throws:
        `javax.xml.transform.TransformerException`

    - #### testCharacters

          protected void testCharacters(java.lang.String name)
                                 throws javax.xml.transform.TransformerException

      Test that all characters in a name are supported in the target encoding
      Throws:
        `javax.xml.transform.TransformerException`

    - #### testCharacters

          protected boolean testCharacters(char[] array,
                               int start,
                               int len)

    - #### endElement

          public void endElement(int nameCode)
                          throws javax.xml.transform.TransformerException

      End of an element.
      Specified by:
        `endElement` in class `Emitter`
      Throws:
        `javax.xml.transform.TransformerException`

    - #### characters

          public void characters(char[] ch,
                        int start,
                        int length)
                          throws javax.xml.transform.TransformerException

      Character data.
      Specified by:
        `characters` in class `Emitter`
      Throws:
        `javax.xml.transform.TransformerException`

    - #### processingInstruction

          public void processingInstruction(java.lang.String target,
                                   java.lang.String data)
                                     throws javax.xml.transform.TransformerException

      Handle a processing instruction.
      Specified by:
        `processingInstruction` in class `Emitter`
      Throws:
        `javax.xml.transform.TransformerException`

    - #### writeEscape

          protected void writeEscape(char[] ch,
                         int start,
                         int length,
                         boolean inAttribute)
                              throws java.io.IOException

      Write contents of array to current writer, after escaping special characters
      Parameters:
        `ch` - The character array containing the string
        `start` - The start position of the input string within the character array
        `length` - The length of the input string within the character array This method converts the XML special characters (such as < and &) into their predefined entities.
      Throws:
        `java.io.IOException`

    - #### outputCharacterReference

          protected void outputCharacterReference(int charval)
                                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### setEscaping

          public void setEscaping(boolean escaping)

      Set escaping on or off
      Overrides:
        `setEscaping` in class `Emitter`

    - #### comment

          public void comment(char[] ch,
                     int start,
                     int length)
                       throws javax.xml.transform.TransformerException

      Handle a comment.
      Specified by:
        `comment` in class `Emitter`
      Throws:
        `javax.xml.transform.TransformerException`

    - #### setResult

          public void setResult(javax.xml.transform.Result result)

      Set the result destination

    - #### setOutputProperties

          public void setOutputProperties(java.util.Properties details)

      Set output properties
      Overrides:
        `setOutputProperties` in class `Emitter`

    - #### setUnparsedEntity

          public void setUnparsedEntity(java.lang.String name,
                               java.lang.String uri)
                                 throws javax.xml.transform.TransformerException

      Set the URI for an unparsed entity in the document.
      Overrides:
        `setUnparsedEntity` in class `Emitter`
      Throws:
        `javax.xml.transform.TransformerException`