net.sf.saxon.event

Class XMLEmitter

public class XMLEmitter extends Emitter

XMLEmitter is an Emitter that generates XML output to a specified destination.
Field Summary
protected booleandeclarationIsWritten
protected intelementCode
protected StackelementStack
protected booleanempty
protected booleanopenStartTag
protected booleanpreferHex
static boolean[]specialInAtt
static boolean[]specialInText
protected booleanundeclareNamespaces
Method Summary
voidattribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties)
voidcharacters(CharSequence chars, int locationId, int properties)
Character data.
voidclose()
End of the document.
voidcloseStartTag()
voidcomment(CharSequence chars, int locationId, int properties)
Handle a comment.
protected StringemptyElementTagCloser(String displayName, int nameCode)
Close an empty element tag.
voidendDocument()
Notify the end of a document node
voidendElement()
End of an element.
static voidmain(String[] params)
voidnamespace(int namespaceCode, int properties)
voidopen()
Start of the event stream.
protected voidopenDocument()
Do the real work of starting the document.
protected voidoutputCharacterReference(int charval)
voidprocessingInstruction(String target, CharSequence data, int locationId, int properties)
Handle a processing instruction.
voidstartContent()
voidstartDocument(int properties)
Start of a document node.
voidstartElement(int nameCode, int typeCode, int locationId, int properties)
Start of an element.
protected inttestCharacters(CharSequence chars)
Test that all characters in a name are supported in the target encoding.
protected voidwriteAttribute(int elCode, String attname, CharSequence value, int properties)
Write attribute name=value pair.
voidwriteCharSequence(CharSequence s)
Write a CharSequence: various implementations
voidwriteDeclaration()
Output the XML declaration
protected voidwriteDocType(String type, String systemId, String publicId)
Output the document type declaration
protected voidwriteEscape(CharSequence chars, boolean inAttribute)
Write contents of array to current writer, after escaping special characters.

Field Detail

declarationIsWritten

protected boolean declarationIsWritten

elementCode

protected int elementCode

elementStack

protected Stack elementStack

empty

protected boolean empty

openStartTag

protected boolean openStartTag

preferHex

protected boolean preferHex

specialInAtt

static boolean[] specialInAtt

specialInText

static boolean[] specialInText

undeclareNamespaces

protected boolean undeclareNamespaces

Method Detail

attribute

public void attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties)

characters

public void characters(CharSequence chars, int locationId, int properties)
Character data.

close

public void close()
End of the document. Close the output stream.

closeStartTag

public void closeStartTag()

comment

public void comment(CharSequence chars, int locationId, int properties)
Handle a comment.

emptyElementTagCloser

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

endDocument

public void endDocument()
Notify the end of a document node

endElement

public void endElement()
End of an element.

main

public static void main(String[] params)

namespace

public void namespace(int namespaceCode, int properties)

open

public void open()
Start of the event stream. Nothing is done at this stage: the opening of the output file is deferred until some content is written to it.

openDocument

protected void openDocument()
Do the real work of starting the document. This happens when the first content is written.

Throws: XPathException

outputCharacterReference

protected void outputCharacterReference(int charval)

processingInstruction

public void processingInstruction(String target, CharSequence data, int locationId, int properties)
Handle a processing instruction.

startContent

public void startContent()

startDocument

public void startDocument(int properties)
Start of a document node. Nothing is done at this stage: the opening of the output file is deferred until some content is written to it.

startElement

public void startElement(int nameCode, int typeCode, int locationId, int properties)
Start of an element. Output the start tag, escaping special characters.

testCharacters

protected int testCharacters(CharSequence chars)
Test that all characters in a name are supported in the target encoding.

Returns: zero if all the characters are available, or the value of the first offending character if not

writeAttribute

protected void writeAttribute(int elCode, String attname, CharSequence value, int properties)
Write attribute name=value pair.

Parameters: elCode The element name is not used in this version of the method, but is used in the HTML subclass. attname The attribute name, which has already been validated to ensure it can be written in this encoding value The value of the attribute properties Any special properties of the attribute

writeCharSequence

public void writeCharSequence(CharSequence s)
Write a CharSequence: various implementations

writeDeclaration

public void writeDeclaration()
Output the XML declaration

writeDocType

protected void writeDocType(String type, String systemId, String publicId)
Output the document type declaration

writeEscape

protected void writeEscape(CharSequence chars, boolean inAttribute)
Write contents of array to current writer, after escaping special characters. This method converts the XML special characters (such as < and &) into their predefined entities.

Parameters: chars The character sequence containing the string inAttribute Set to true if the text is in an attribute value