Package com.icl.saxon.output
Class XMLEmitter
- java.lang.Object
-
- com.icl.saxon.output.Emitter
-
- com.icl.saxon.output.XMLEmitter
-
- All Implemented Interfaces:
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 Description protected CharacterSetcharacterSetprotected booleandeclarationIsWrittenprotected booleanemptyprotected booleanescapingprotected StringlastDisplayNameprotected intlastNameCodeprotected StringlastPrefixprotected StringlastURIprotected booleanopenStartTagprotected booleanpreferHex-
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 Description XMLEmitter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)Character data.protected voidcloseStartTag(int nameCode, boolean emptyTag)voidcomment(char[] ch, int start, int length)Handle a comment.protected StringemptyElementTagCloser(int nameCode)Close an empty element tag.voidendDocument()End of the document.voidendElement(int nameCode)End of an element.protected voidoutputCharacterReference(int charval)voidprocessingInstruction(String target, String data)Handle a processing instruction.voidsetDocumentLocator(Locator locator)Set Document Locator.voidsetEscaping(boolean escaping)Set escaping on or offvoidsetOutputProperties(Properties details)Set output propertiesvoidsetResult(Result result)Set the result destinationvoidsetUnparsedEntity(String name, String uri)Set the URI for an unparsed entity in the document.voidstartDocument()Start of the document.voidstartElement(int nameCode, Attributes attributes, int[] namespaces, int nscount)Start of an element.protected booleantestCharacters(char[] array, int start, int len)protected voidtestCharacters(String name)Test that all characters in a name are supported in the target encodingprotected voidwriteAttribute(int elCode, String attname, String type, String value)voidwriteDeclaration()Output the XML declarationprotected voidwriteDocType(String type, String systemId, String publicId)protected voidwriteEscape(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
-
-
-
-
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 String lastDisplayName
-
lastPrefix
protected String lastPrefix
-
lastURI
protected String lastURI
-
-
Method Detail
-
setDocumentLocator
public void setDocumentLocator(Locator locator)
Set Document Locator. Provided merely to satisfy the interface.- Overrides:
setDocumentLocatorin classEmitter
-
startDocument
public void startDocument() throws TransformerExceptionStart of the document. Make the writer and write the XML declaration.- Specified by:
startDocumentin classEmitter- Throws:
TransformerException
-
writeDeclaration
public void writeDeclaration() throws TransformerExceptionOutput the XML declaration- Throws:
TransformerException
-
writeDocType
protected void writeDocType(String type, String systemId, String publicId) throws TransformerException
- Throws:
TransformerException
-
endDocument
public void endDocument() throws TransformerExceptionEnd of the document. Close the output stream.- Specified by:
endDocumentin classEmitter- Throws:
TransformerException
-
startElement
public void startElement(int nameCode, Attributes attributes, int[] namespaces, int nscount) throws TransformerExceptionStart of an element. Output the start tag, escaping special characters.- Specified by:
startElementin classEmitternamespaces- Array of namespace codes identifying the namespace prefix/uri pairs associated with this elementnscount- Number of significant entries within namespaces array- Throws:
TransformerException
-
closeStartTag
protected void closeStartTag(int nameCode, boolean emptyTag) throws TransformerException- Throws:
TransformerException
-
emptyElementTagCloser
protected String emptyElementTagCloser(int nameCode)
Close an empty element tag. (This is overridden in XHTMLEmitter).
-
writeAttribute
protected void writeAttribute(int elCode, String attname, String type, String value) throws TransformerException- Throws:
TransformerException
-
testCharacters
protected void testCharacters(String name) throws TransformerException
Test that all characters in a name are supported in the target encoding- Throws:
TransformerException
-
testCharacters
protected boolean testCharacters(char[] array, int start, int len)
-
endElement
public void endElement(int nameCode) throws TransformerExceptionEnd of an element.- Specified by:
endElementin classEmitter- Throws:
TransformerException
-
characters
public void characters(char[] ch, int start, int length) throws TransformerExceptionCharacter data.- Specified by:
charactersin classEmitter- Throws:
TransformerException
-
processingInstruction
public void processingInstruction(String target, String data) throws TransformerException
Handle a processing instruction.- Specified by:
processingInstructionin classEmitter- Throws:
TransformerException
-
writeEscape
protected void writeEscape(char[] ch, int start, int length, boolean inAttribute) throws IOExceptionWrite contents of array to current writer, after escaping special characters- Parameters:
ch- The character array containing the stringstart- The start position of the input string within the character arraylength- 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:
IOException
-
outputCharacterReference
protected void outputCharacterReference(int charval) throws IOException- Throws:
IOException
-
setEscaping
public void setEscaping(boolean escaping)
Set escaping on or off- Overrides:
setEscapingin classEmitter
-
comment
public void comment(char[] ch, int start, int length) throws TransformerExceptionHandle a comment.- Specified by:
commentin classEmitter- Throws:
TransformerException
-
setResult
public void setResult(Result result)
Set the result destination
-
setOutputProperties
public void setOutputProperties(Properties details)
Set output properties- Overrides:
setOutputPropertiesin classEmitter
-
setUnparsedEntity
public void setUnparsedEntity(String name, String uri) throws TransformerException
Set the URI for an unparsed entity in the document.- Overrides:
setUnparsedEntityin classEmitter- Throws:
TransformerException
-
-