Package net.sf.saxon.event
Class StreamWriterToReceiver
java.lang.Object
net.sf.saxon.event.StreamWriterToReceiver
- All Implemented Interfaces:
XMLStreamWriter
- Direct Known Subclasses:
BuildingStreamWriterImpl
This class implements the XmlStreamWriter interface, translating the events into Saxon
Receiver events. The Receiver can be anything: a serializer, a schema validator, a tree builder.
The class will attempt to generate namespace prefixes where none have been supplied, unless the
inventPrefixes
option is set to false. The preferred mode of use is to call the versions
of writeStartElement
and writeAttribute
that supply the prefix, URI, and
local name in full. If the prefix is omitted, the class attempts to invent a prefix. If the URI is
omitted, the name is assumed to be in no namespace. The writeNamespace
The class will check all names, URIs, and character content for conformance against XML well-formedness
rules unless the checkValues
option is set to false.
- Since:
- 9.3
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
flush()
getProperty
(String name) boolean
Ask whether names and values are to be checked for conformance with XML rulesboolean
Ask whether prefixes are to be invented when none is specified by the uservoid
setCheckValues
(boolean check) Say whether names and values are to be checked for conformance with XML rulesvoid
void
setInventPrefixes
(boolean invent) Say whether prefixes are to be invented when none is specified by the uservoid
setNamespaceContext
(NamespaceContext context) void
void
writeAttribute
(String localName, String value) void
writeAttribute
(String namespaceURI, String localName, String value) void
writeAttribute
(String prefix, String namespaceURI, String localName, String value) void
writeCData
(String data) void
writeCharacters
(char[] text, int start, int len) void
writeCharacters
(String text) void
writeComment
(String data) void
writeDefaultNamespace
(String namespaceURI) void
void
writeEmptyElement
(String localName) void
writeEmptyElement
(String namespaceURI, String localName) void
writeEmptyElement
(String prefix, String localName, String namespaceURI) void
void
void
writeEntityRef
(String name) void
writeNamespace
(String prefix, String namespaceURI) void
writeProcessingInstruction
(String target) void
writeProcessingInstruction
(String target, String data) void
void
writeStartDocument
(String version) void
writeStartDocument
(String encoding, String version) void
writeStartElement
(String localName) void
writeStartElement
(String namespaceURI, String localName) void
writeStartElement
(String prefix, String localName, String namespaceURI)
-
Constructor Details
-
StreamWriterToReceiver
Constructor. Creates a StreamWriter as a front-end to a given Receiver.- Parameters:
receiver
- the Receiver that is to receive the events generated by this StreamWriter.
-
-
Method Details
-
setInventPrefixes
public void setInventPrefixes(boolean invent) Say whether prefixes are to be invented when none is specified by the user- Parameters:
invent
- true if prefixes are to be invented. Default is true;
-
isInventPrefixes
public boolean isInventPrefixes()Ask whether prefixes are to be invented when none is specified by the user- Returns:
- true if prefixes are to be invented. Default is true;
-
setCheckValues
public void setCheckValues(boolean check) Say whether names and values are to be checked for conformance with XML rules- Parameters:
check
- true if names and values are to be checked. Default is true;
-
isCheckValues
public boolean isCheckValues()Ask whether names and values are to be checked for conformance with XML rules- Returns:
- true if names and values are to be checked. Default is true;
-
writeStartElement
- Specified by:
writeStartElement
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeStartElement
- Specified by:
writeStartElement
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeStartElement
public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException - Specified by:
writeStartElement
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeEmptyElement
- Specified by:
writeEmptyElement
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeEmptyElement
public void writeEmptyElement(String prefix, String localName, String namespaceURI) throws XMLStreamException - Specified by:
writeEmptyElement
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeEmptyElement
- Specified by:
writeEmptyElement
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeEndElement
- Specified by:
writeEndElement
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeEndDocument
- Specified by:
writeEndDocument
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
close
- Specified by:
close
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
flush
- Specified by:
flush
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeAttribute
- Specified by:
writeAttribute
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String prefix, String namespaceURI, String localName, String value) throws XMLStreamException - Specified by:
writeAttribute
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException - Specified by:
writeAttribute
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeNamespace
- Specified by:
writeNamespace
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeDefaultNamespace
- Specified by:
writeDefaultNamespace
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeComment
- Specified by:
writeComment
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeProcessingInstruction
- Specified by:
writeProcessingInstruction
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeProcessingInstruction
- Specified by:
writeProcessingInstruction
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeCData
- Specified by:
writeCData
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeDTD
- Specified by:
writeDTD
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeEntityRef
- Specified by:
writeEntityRef
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeStartDocument
- Specified by:
writeStartDocument
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeStartDocument
- Specified by:
writeStartDocument
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeStartDocument
- Specified by:
writeStartDocument
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeCharacters
- Specified by:
writeCharacters
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeCharacters
- Specified by:
writeCharacters
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
getPrefix
- Specified by:
getPrefix
in interfaceXMLStreamWriter
-
setPrefix
- Specified by:
setPrefix
in interfaceXMLStreamWriter
-
setDefaultNamespace
- Specified by:
setDefaultNamespace
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
setNamespaceContext
- Specified by:
setNamespaceContext
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
getNamespaceContext
- Specified by:
getNamespaceContext
in interfaceXMLStreamWriter
-
getProperty
- Specified by:
getProperty
in interfaceXMLStreamWriter
- Throws:
IllegalArgumentException
-