com.icl.saxon.output

Class XMLEmitter

Implemented Interfaces:
Result
Known Direct Subclasses:
HTMLEmitter, MessageEmitter, TEXTEmitter, XHTMLEmitter

public class XMLEmitter
extends Emitter

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

Nested Class Summary

Field Summary

protected CharacterSet
characterSet
protected boolean
declarationIsWritten
protected boolean
empty
protected boolean
escaping
protected String
lastDisplayName
protected int
lastNameCode
protected String
lastPrefix
protected String
lastURI
protected boolean
openStartTag
protected boolean
preferHex

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

locator, namePool, outputProperties, outputStream, systemId, writer

Method Summary

void
characters(char[] ch, int start, int length)
Character data.
protected void
closeStartTag(int nameCode, boolean emptyTag)
void
comment(ch[] , int start, int length)
Handle a comment.
protected 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(String target, String data)
Handle a processing instruction.
void
setDocumentLocator(Locator locator)
Set Document Locator.
void
setEscaping(boolean escaping)
Set escaping on or off
void
setOutputProperties(Properties details)
Set output properties
void
setResult(Result result)
Set the result destination
void
setUnparsedEntity(String name, String uri)
Set the URI for an unparsed entity in the document.
void
startDocument()
Start of the document.
void
startElement(int nameCode, Attributes attributes, int[] namespaces, int nscount)
Start of an element.
protected void
testCharacters(String name)
Test that all characters in a name are supported in the target encoding
protected boolean
testCharacters(char[] array, int start, int len)
protected void
writeAttribute(int elCode, String attname, String type, String value)
void
writeDeclaration()
Output the XML declaration
protected void
writeDocType(String type, String systemId, String publicId)
protected void
writeEscape(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

characters, comment, endDocument, endElement, getNamePool, getOutputProperties, getOutputStream, getSystemId, getWriter, makeEmitter, processingInstruction, setDocumentLocator, setEscaping, setNamePool, setOutputProperties, setOutputStream, setSystemId, setUnparsedEntity, setWriter, startDocument, startElement, usesWriter

Field Details

characterSet

protected CharacterSet characterSet


declarationIsWritten

protected boolean declarationIsWritten


empty

protected boolean empty


escaping

protected boolean escaping


lastDisplayName

protected String lastDisplayName


lastNameCode

protected int lastNameCode


lastPrefix

protected String lastPrefix


lastURI

protected String lastURI


openStartTag

protected boolean openStartTag


preferHex

protected boolean preferHex

Method Details

characters

public void characters(char[] ch,
                       int start,
                       int length)
            throws TransformerException
Character data.
Overrides:
characters in interface Emitter


closeStartTag

protected void closeStartTag(int nameCode,
                             boolean emptyTag)
            throws TransformerException


comment

public void comment(ch[] ,
                    int start,
                    int length)
            throws TransformerException
Handle a comment.


emptyElementTagCloser

protected String emptyElementTagCloser(int nameCode)
Close an empty element tag. (This is overridden in XHTMLEmitter).


endDocument

public void endDocument()
            throws TransformerException
End of the document. Close the output stream.
Overrides:
endDocument in interface Emitter


endElement

public void endElement(int nameCode)
            throws TransformerException
End of an element.
Overrides:
endElement in interface Emitter


outputCharacterReference

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


processingInstruction

public void processingInstruction(String target,
                                  String data)
            throws TransformerException
Handle a processing instruction.
Overrides:
processingInstruction in interface Emitter


setDocumentLocator

public void setDocumentLocator(Locator locator)
Set Document Locator. Provided merely to satisfy the interface.
Overrides:
setDocumentLocator in interface Emitter


setEscaping

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


setOutputProperties

public void setOutputProperties(Properties details)
Set output properties
Overrides:
setOutputProperties in interface Emitter


setResult

public void setResult(Result result)
Set the result destination


setUnparsedEntity

public void setUnparsedEntity(String name,
                              String uri)
            throws TransformerException
Set the URI for an unparsed entity in the document.
Overrides:
setUnparsedEntity in interface Emitter


startDocument

public void startDocument()
            throws TransformerException
Start of the document. Make the writer and write the XML declaration.
Overrides:
startDocument in interface Emitter


startElement

public void startElement(int nameCode,
                         Attributes attributes,
                         int[] namespaces,
                         int nscount)
            throws TransformerException
Start of an element. Output the start tag, escaping special characters.
Overrides:
startElement in interface Emitter


testCharacters

protected void testCharacters(String name)
            throws TransformerException
Test that all characters in a name are supported in the target encoding


testCharacters

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


writeAttribute

protected void writeAttribute(int elCode,
                              String attname,
                              String type,
                              String value)
            throws TransformerException


writeDeclaration

public void writeDeclaration()
            throws TransformerException
Output the XML declaration


writeDocType

protected void writeDocType(String type,
                            String systemId,
                            String publicId)
            throws TransformerException


writeEscape

protected void writeEscape(ch[] ,
                           int start,
                           int length,
                           boolean inAttribute)
            throws java.io.IOException
Write contents of array to current writer, after escaping special characters

Parameters:
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 <32and &) into their predefined entities.