public class XMLEmitter extends Emitter
Modifier and Type | Field and Description |
---|---|
protected boolean[] |
attSpecials |
protected boolean |
canonical |
protected CharacterReferenceGenerator |
characterReferenceGenerator |
protected boolean |
declarationIsWritten |
protected char |
delimiter |
protected static byte[] |
DOCTYPE |
protected NodeName |
elementCode |
protected java.util.Stack<java.lang.String> |
elementStack |
protected int |
indentForNextAttribute |
protected java.lang.String |
internalSubset |
protected boolean |
openStartTag |
protected static byte[] |
RIGHT_ANGLE_NEWLINE |
protected static boolean[] |
specialInAtt |
protected static boolean[] |
specialInAttSingle |
protected static boolean[] |
specialInText |
protected boolean |
started |
protected boolean |
startedElement |
protected boolean |
undeclareNamespaces |
protected boolean |
unfailing |
allCharactersEncodable, characterSet, outputProperties, writer
pipelineConfiguration, previousAtomic, systemId
Constructor and Description |
---|
XMLEmitter() |
Modifier and Type | Method and Description |
---|---|
void |
characters(UnicodeString chars,
Location locationId,
int properties)
Character data.
|
void |
close()
End of the document.
|
void |
closeStartTag()
Mark the end of the start tag
|
void |
comment(UnicodeString chars,
Location locationId,
int properties)
Handle a comment.
|
protected UnicodeString |
convertToAscii(UnicodeString chars)
Where characters are not available in the selected encoding, substitute them
|
void |
endDocument()
Notify the end of a document node
|
void |
endElement()
End of an element.
|
boolean |
isStarted()
Ask whether anything has yet been written
|
void |
namespace(java.lang.String nsprefix,
java.lang.String nsuri,
boolean isFirst) |
void |
open()
Start of the event stream.
|
protected void |
openDocument()
Do the real work of starting the document.
|
void |
processingInstruction(java.lang.String target,
UnicodeString data,
Location locationId,
int properties)
Handle a processing instruction.
|
void |
setCharacterReferenceGenerator(CharacterReferenceGenerator generator)
Set the character reference generator to be used for generating hexadecimal or decimal
character references
|
void |
setEscapeNonAscii(java.lang.Boolean escape)
Say that all non-ASCII characters should be escaped, regardless of the character encoding
|
void |
setIndentForNextAttribute(int indent)
Set the indentation to be used for attributes (this excludes the length of the
element name itself)
|
void |
startDocument(int properties)
Start of a document node.
|
void |
startElement(NodeName elemName,
SchemaType type,
AttributeMap attributes,
NamespaceMap namespaces,
Location location,
int properties)
Start of an element.
|
protected int |
testCharacters(UnicodeString chars)
Test that all characters in a name (for example) are supported in the target encoding.
|
boolean |
usesTypeAnnotations()
Ask whether this Receiver (or the downstream pipeline) makes any use of the type annotations
supplied on element and attribute events
|
protected void |
writeAttribute(NodeName elCode,
java.lang.String attname,
java.lang.String value,
int properties)
Write attribute name=value pair.
|
protected void |
writeAttributeIndentString() |
protected void |
writeCodePoint(int c) |
void |
writeDeclaration()
Output the XML declaration
|
protected void |
writeDocType(NodeName name,
java.lang.String displayName,
java.lang.String systemId,
java.lang.String publicId)
Output the document type declaration
|
protected boolean |
writeDocTypeWithNullSystemId() |
protected void |
writeEmptyElementTagCloser(java.lang.String displayName,
NodeName nameCode)
Close an empty element tag.
|
protected void |
writeEscape(UnicodeString chars,
boolean inAttribute)
Write contents of array to current writer, after escaping special characters.
|
append, getOutputProperties, setMustClose, setOutputProperties, setUnicodeWriter, setUnparsedEntity
append, decompose, flatten, getConfiguration, getErrorCodeForDecomposingFunctionItems, getNamePool, getPipelineConfiguration, getSystemId, handlesAppend, setPipelineConfiguration, setSystemId
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
append, getPipelineConfiguration, handlesAppend, setPipelineConfiguration
protected boolean canonical
protected boolean started
protected boolean startedElement
protected boolean openStartTag
protected boolean declarationIsWritten
protected NodeName elementCode
protected int indentForNextAttribute
protected boolean undeclareNamespaces
protected boolean unfailing
protected java.lang.String internalSubset
protected char delimiter
protected boolean[] attSpecials
protected java.util.Stack<java.lang.String> elementStack
protected CharacterReferenceGenerator characterReferenceGenerator
protected static boolean[] specialInText
protected static boolean[] specialInAtt
protected static boolean[] specialInAttSingle
protected static final byte[] DOCTYPE
protected static final byte[] RIGHT_ANGLE_NEWLINE
public void setCharacterReferenceGenerator(CharacterReferenceGenerator generator)
generator
- the character reference generator to be usedpublic void setEscapeNonAscii(java.lang.Boolean escape)
escape
- true if all non ASCII characters should be escapedpublic void open() throws XPathException
open
in interface Receiver
open
in class SequenceReceiver
XPathException
- if an error occurspublic void startDocument(int properties) throws XPathException
properties
- bit-significant integer indicating properties of the document node.
The definitions of the bits are in class ReceiverOption
XPathException
- if an error occurspublic void endDocument() throws XPathException
XPathException
- if an error occursprotected void openDocument() throws XPathException
XPathException
- if an error occurs opening the output filepublic void writeDeclaration() throws XPathException
XPathException
- if any error occursprotected void writeDocType(NodeName name, java.lang.String displayName, java.lang.String systemId, java.lang.String publicId) throws XPathException
name
- the qualified name of the elementdisplayName
- The element name as displayedsystemId
- The DOCTYPE system identifierpublicId
- The DOCTYPE public identifierXPathException
- if an error occurs writing to the outputpublic void close() throws XPathException
close
in interface Receiver
close
in class Emitter
XPathException
- if an error occurspublic void startElement(NodeName elemName, SchemaType type, AttributeMap attributes, NamespaceMap namespaces, Location location, int properties) throws XPathException
elemName
- the name of the elementtype
- the type annotation of the elementattributes
- the attributes of this elementnamespaces
- the in-scope namespaces of this element: generally this is all the in-scope
namespaces, without relying on inheriting namespaces from parent elementslocation
- an object providing information about the module, line, and column where the node originatedproperties
- bit-significant properties of the element node. If there are no relevant
properties, zero is supplied. The definitions of the bits are in class ReceiverOption
XPathException
- if an error occursprotected boolean writeDocTypeWithNullSystemId()
public void namespace(java.lang.String nsprefix, java.lang.String nsuri, boolean isFirst) throws XPathException
XPathException
public void setIndentForNextAttribute(int indent)
indent
- the number of spaces to be output before each attribute (on a new line)protected void writeAttributeIndentString() throws java.io.IOException
java.io.IOException
public void closeStartTag() throws XPathException
XPathException
- if an IO exception occursprotected void writeEmptyElementTagCloser(java.lang.String displayName, NodeName nameCode) throws java.io.IOException
displayName
- the name of the empty elementnameCode
- the fingerprint of the name of the empty elementjava.io.IOException
- if an IO exception occursprotected void writeAttribute(NodeName elCode, java.lang.String attname, java.lang.String value, int properties) throws XPathException
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 encodingvalue
- The value of the attributeproperties
- Any special properties of the attributeXPathException
- if an error occursprotected int testCharacters(UnicodeString chars)
chars
- the characters to be testedprotected UnicodeString convertToAscii(UnicodeString chars)
chars
- the characters to be convertedpublic void endElement() throws XPathException
XPathException
- if an error occurspublic void characters(UnicodeString chars, Location locationId, int properties) throws XPathException
chars
- The characterslocationId
- provides information such as line number and system ID.properties
- Bit significant value. The following bits are defined:
XPathException
- if an error occurspublic void processingInstruction(java.lang.String target, UnicodeString data, Location locationId, int properties) throws XPathException
target
- The PI name. This must be a legal name (it will not be checked).data
- The data portion of the processing instructionlocationId
- provides information such as line number and system ID.properties
- Additional information about the PI.XPathException
- if an error occursprotected void writeEscape(UnicodeString chars, boolean inAttribute) throws java.io.IOException, XPathException
chars
- The character sequence containing the stringinAttribute
- Set to true if the text is in an attribute valuejava.io.IOException
- if an IO exception occursXPathException
- if an IO exception occursprotected void writeCodePoint(int c) throws java.io.IOException
java.io.IOException
public void comment(UnicodeString chars, Location locationId, int properties) throws XPathException
chars
- The content of the commentlocationId
- provides information such as line number and system ID.properties
- Additional information about the comment.XPathException
- if an error occurspublic boolean usesTypeAnnotations()
usesTypeAnnotations
in interface Receiver
usesTypeAnnotations
in class Emitter
public boolean isStarted()
Copyright (c) 2004-2022 Saxonica Limited. All rights reserved.