com.icl.saxon.output
Class XMLEmitter

java.lang.Object
  |
  +--com.icl.saxon.output.XMLEmitter
All Implemented Interfaces:
Emitter
Direct Known Subclasses:
DTDEmitter, HTMLEmitter, MessageEmitter, TEXTEmitter, XHTMLEmitter

public class XMLEmitter
extends java.lang.Object
implements Emitter

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


Field Summary
protected  CharacterSet characterSet
           
protected  boolean declarationIsWritten
           
protected  boolean empty
           
protected  boolean escaping
           
protected  boolean openStartTag
           
protected  OutputDetails outputDetails
           
protected  java.io.Writer writer
           
 
Constructor Summary
XMLEmitter()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          Character data.
protected  void closeStartTag(java.lang.String name, boolean emptyTag)
           
 void comment(char[] ch, int start, int length)
          Handle a comment.
protected  java.lang.String emptyElementTagCloser(java.lang.String name)
          Close an empty element tag.
 void endDocument()
          End of the document.
 void endElement(Name name)
          End of an element.
protected  void outputCharacterReference(int charval)
           
 void processingInstruction(java.lang.String target, java.lang.String data)
          Handle a processing instruction.
 void setCharacterSet(CharacterSet charSet)
          Set the character set to use
 void setDocumentLocator(org.xml.sax.Locator locator)
          Set Document Locator.
 void setEscaping(boolean escaping)
          Set escaping on or off
 void setOutputDetails(OutputDetails details)
          Set output details
 void setWriter(java.io.Writer writer)
          Set the Writer to use
 void startDocument()
          Start of the document.
 void startElement(Name fullname, AttributeCollection attributes)
          Start of an element.
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          Start a namespace prefix mapping.
protected  void 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 unwindNamespaces()
          Discard the namespaces declared on this element.
protected  void writeAttribute(java.lang.String elname, 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)
          Output the document type declaration
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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writer

protected java.io.Writer writer

characterSet

protected CharacterSet characterSet

outputDetails

protected OutputDetails outputDetails

empty

protected boolean empty

escaping

protected boolean escaping

openStartTag

protected boolean openStartTag

declarationIsWritten

protected boolean declarationIsWritten
Constructor Detail

XMLEmitter

public XMLEmitter()
Method Detail

setWriter

public void setWriter(java.io.Writer writer)
Set the Writer to use
Specified by:
setWriter in interface Emitter

setCharacterSet

public void setCharacterSet(CharacterSet charSet)
Set the character set to use
Specified by:
setCharacterSet in interface Emitter

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Set Document Locator. Provided merely to satisfy the interface.

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Start of the document. Make the writer and write the XML declaration.
Specified by:
startDocument in interface Emitter

writeDeclaration

public void writeDeclaration()
                      throws org.xml.sax.SAXException
Output the XML declaration

writeDocType

protected void writeDocType(java.lang.String type,
                            java.lang.String systemId,
                            java.lang.String publicId)
                     throws org.xml.sax.SAXException
Output the document type declaration

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
End of the document. Close the output stream.
Specified by:
endDocument in interface Emitter

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Start a namespace prefix mapping. All prefixes used in element or attribute names will be notified before the relevant startElement call
Specified by:
startPrefixMapping in interface Emitter

startElement

public void startElement(Name fullname,
                         AttributeCollection attributes)
                  throws org.xml.sax.SAXException
Start of an element. Output the start tag, escaping special characters.
Specified by:
startElement in interface Emitter

closeStartTag

protected void closeStartTag(java.lang.String name,
                             boolean emptyTag)
                      throws org.xml.sax.SAXException

emptyElementTagCloser

protected java.lang.String emptyElementTagCloser(java.lang.String name)
Close an empty element tag. (This is overridden in XHTMLEmitter).

writeAttribute

protected void writeAttribute(java.lang.String elname,
                              java.lang.String attname,
                              java.lang.String type,
                              java.lang.String value)
                       throws org.xml.sax.SAXException

testCharacters

protected void testCharacters(java.lang.String name)
                       throws org.xml.sax.SAXException
Test that all characters in a name are supported in the target encoding

testCharacters

protected void testCharacters(char[] array,
                              int start,
                              int len)
                       throws org.xml.sax.SAXException

endElement

public void endElement(Name name)
                throws org.xml.sax.SAXException
End of an element.
Specified by:
endElement in interface Emitter

unwindNamespaces

protected void unwindNamespaces()
                         throws org.xml.sax.SAXException
Discard the namespaces declared on this element. Separate from endElement() so it can be called from a subclass.

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Character data.
Specified by:
characters in interface Emitter

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Handle a processing instruction.
Specified by:
processingInstruction in interface Emitter

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.

outputCharacterReference

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

setEscaping

public void setEscaping(boolean escaping)
Set escaping on or off
Specified by:
setEscaping in interface Emitter

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws org.xml.sax.SAXException
Handle a comment.
Specified by:
comment in interface Emitter

setOutputDetails

public void setOutputDetails(OutputDetails details)
Set output details
Specified by:
setOutputDetails in interface Emitter
Following copied from interface: com.icl.saxon.output.Emitter
Parameters:
details - The details of the required output