XMLEventWriter (Java SE 15 & JDK 15) (original) (raw)

All Superinterfaces:

[XMLEventConsumer](util/XMLEventConsumer.html "interface in javax.xml.stream.util")


public interface XMLEventWriter extends XMLEventConsumer

This is the top level interface for writing XML documents. Instances of this interface are not required to validate the form of the XML.

Since:

1.6

See Also:

XMLEventReader, XMLEvent, Characters, ProcessingInstruction, StartElement, EndElement

Modifier and Type Method Description
void add​(XMLEvent event) Add an event to the output stream Adding a START_ELEMENT will open a new namespace scope that will be closed when the corresponding END_ELEMENT is written.
void add​(XMLEventReader reader) Adds an entire stream to an output stream, calls next() on the inputStream argument until hasNext() returns false This should be treated as a convenience method that will perform the following loop over all the events in an event reader and call add on each event.
void close() Frees any resources associated with this stream
void flush() Writes any cached events to the underlying output mechanism
NamespaceContext getNamespaceContext() Returns the current namespace context.
String getPrefix​(String uri) Gets the prefix the uri is bound to
void setDefaultNamespace​(String uri) Binds a URI to the default namespace This URI is bound in the scope of the current START_ELEMENT / END_ELEMENT pair.
void setNamespaceContext​(NamespaceContext context) Sets the current namespace context for prefix and uri bindings.
void setPrefix​(String prefix,String uri) Sets the prefix the uri is bound to.