Top Description Fields Constructors Methods
org.jdom2.input

public Class StAXStreamWriter

extends Object
implements XMLStreamWriter
Class Inheritance
All Implemented Interfaces
javax.xml.stream.XMLStreamWriter
Imports
java.util.ArrayList, .LinkedList, javax.xml.namespace.NamespaceContext, javax.xml.stream.XMLStreamException, .XMLStreamWriter, org.jdom2.DefaultJDOMFactory, .Document, .Element, .JDOMConstants, .JDOMFactory, .Namespace, .Parent, .Text, org.jdom2.util.JDOMNamespaceContext, .NamespaceStack

An XMLStreamWriter implementation that writes XML data to a new JDOM Document. The document can be retrieved using getDocument().

This class is the inverse of the class StAXStreamBuilder in the sense that this class is written to (it's an XMLStreamWriter implementation) to create a JDOM Document whereas the StAXStreamBuilder reads from a user-supplied XMLStreamReader. It is the difference between a 'push' concept and a 'pull' concept.

An interesting read for people using this class: Apache Axiom notes on setPrefix().

Authors
gordon burgett https://github.com/gburgett, Rolf Lear
Since
JDOM 2.1

Field Summary

Modifier and TypeField and Description
private Element
private Text
private NamespaceStack
private static final DefaultJDOMFactory
private Document
private boolean
private final JDOMFactory
private int
private NamespaceContext
private boolean
private Parent
private LinkedList<Namespace>
private final boolean
private NamespaceStack

Constructor Summary

AccessConstructor and Description
public
StAXStreamWriter()

Create a StAXStreamWriter with the default JDOMFactory for creating JDOM Content.

public
StAXStreamWriter(final JDOMFactory
The JDOMFactory to use.
fac
,
final boolean
If true, then repair namespace errors.
repairnamespace
)

Create a StAXStreamWriter with the specified JDOMFactory for creating JDOM Content.

Method Summary

Modifier and TypeMethod and Description
private final void
buildAttribute(final String prefix, final String namespaceURI, final String localName, final String value, final boolean withpfx)

private final void
buildElement(final String
The namespace prefix (may be null).
prefix
,
final String
The Element tag
localName
,
final String
The namespace URI (may be null).
namespaceURI
,
final boolean
whether the prefix is user-specified
withpfx
,
boolean
Is this an Empty element (expecting children?)
empty
)

Simple method that implements the empty-element logic without the spec-required null-check logic

public void
close()

Implements javax.xml.stream.XMLStreamWriter.close.

Close this writer and free any resources associated with the writer.
public void
flush()

Implements javax.xml.stream.XMLStreamWriter.flush.

Write any cached data to the underlying output mechanism.
private final void
private final void
private String
public Document

Returns:

The created Document
getDocument
()

Gets the Document that was created by this writer.

public NamespaceContext
getNamespaceContext()

Implements javax.xml.stream.XMLStreamWriter.getNamespaceContext.

Returns the current namespace context.
public String
getPrefix(final String
the uri the prefix is bound to
uri
)

Implements javax.xml.stream.XMLStreamWriter.getPrefix.

Gets the prefix the uri is bound to.
public Object
getProperty(String
The name of the property, may not be null
name
)

Implements javax.xml.stream.XMLStreamWriter.getProperty.

Get the value of a feature/property from the underlying implementation
private Namespace
resolveAttributeNamespace(String prefix, String namespaceURI, boolean withpfx)

private Namespace
resolveElementNamespace(String prefix, String namespaceURI, boolean withpfx)

public void
setDefaultNamespace(final String
the uri to bind to the default namespace, may be null
uri
)

Implements javax.xml.stream.XMLStreamWriter.setDefaultNamespace.

Binds a URI to the default namespace This URI is bound in the scope of the current START_ELEMENT / END_ELEMENT pair.
public void
setNamespaceContext(final NamespaceContext
the namespace context to use for this writer, may not be null
context
)

Implements javax.xml.stream.XMLStreamWriter.setNamespaceContext.

Sets the current namespace context for prefix and uri bindings.
public void
setPrefix(final String
the prefix to bind to the uri, may not be null
prefix
,
final String
the uri to bind to the prefix, may be null
uri
)

Implements javax.xml.stream.XMLStreamWriter.setPrefix.

Sets the prefix the uri is bound to.
public void
writeAttribute(final String
the local name of the attribute
localName
,
final String
the value of the attribute
value
)

Implements javax.xml.stream.XMLStreamWriter.writeAttribute.

Writes an attribute to the output stream without a prefix.
public void
writeAttribute(final String
the uri of the prefix for this attribute
namespaceURI
,
final String
the local name of the attribute
localName
,
final String
the value of the attribute
value
)

Implements javax.xml.stream.XMLStreamWriter.writeAttribute.

Writes an attribute to the output stream
public void
writeAttribute(final String
the prefix for this attribute
prefix
,
final String
the uri of the prefix for this attribute
namespaceURI
,
final String
the local name of the attribute
localName
,
final String
the value of the attribute
value
)

Implements javax.xml.stream.XMLStreamWriter.writeAttribute.

Writes an attribute to the output stream
public void
writeCData(final String
the data contained in the CData Section, may not be null
data
)

Implements javax.xml.stream.XMLStreamWriter.writeCData.

Writes a CData section
public void
writeCharacters(final String
the value to write
chars
)

Implements javax.xml.stream.XMLStreamWriter.writeCharacters.

Write text to the output
public void
writeCharacters(final char[]
the value to write
chars
,
final int
the starting position in the array
start
,
final int
the number of characters to write
len
)

Implements javax.xml.stream.XMLStreamWriter.writeCharacters.

Write text to the output
public void
writeComment(final String
the data contained in the comment, may be null
data
)

Implements javax.xml.stream.XMLStreamWriter.writeComment.

Writes an xml comment with the data enclosed
public void
writeDefaultNamespace(final String
the uri to bind the default namespace to
namespaceURI
)

Implements javax.xml.stream.XMLStreamWriter.writeDefaultNamespace.

Writes the default namespace to the stream
public void
writeDTD(final String
the DTD to be written
dtd
)

Implements javax.xml.stream.XMLStreamWriter.writeDTD.

Write a DTD section.
public void
writeEmptyElement(final String
local name of the tag, may not be null
localName
)

Implements javax.xml.stream.XMLStreamWriter.writeEmptyElement.

Writes an empty element tag to the output
public void
writeEmptyElement(final String
the uri to bind the tag to, may not be null
namespaceURI
,
final String
local name of the tag, may not be null
localName
)

Implements javax.xml.stream.XMLStreamWriter.writeEmptyElement.

Writes an empty element tag to the output
public void
writeEmptyElement(final String
the prefix of the tag, may not be null
prefix
,
final String
local name of the tag, may not be null
localName
,
final String
the uri to bind the tag to, may not be null
namespaceURI
)

Implements javax.xml.stream.XMLStreamWriter.writeEmptyElement.

Writes an empty element tag to the output
public void
writeEndDocument()

Implements javax.xml.stream.XMLStreamWriter.writeEndDocument.

Closes any start tags and writes corresponding end tags.
public void
writeEndElement()

Implements javax.xml.stream.XMLStreamWriter.writeEndElement.

Writes an end tag to the output relying on the internal state of the writer to determine the prefix and local name of the event.
public void
writeEntityRef(final String
the name of the entity
name
)

Implements javax.xml.stream.XMLStreamWriter.writeEntityRef.

Writes an entity reference
public void
writeNamespace(final String
the prefix to bind this namespace to
prefix
,
final String
the uri to bind the prefix to
namespaceURI
)

Implements javax.xml.stream.XMLStreamWriter.writeNamespace.

Writes a namespace to the output stream If the prefix argument to this method is the empty string, "xmlns", or null this method will delegate to writeDefaultNamespace
public void
writeProcessingInstruction(final String
the target of the processing instruction, may not be null
target
)

Implements javax.xml.stream.XMLStreamWriter.writeProcessingInstruction.

Writes a processing instruction
public void
writeProcessingInstruction(final String
the target of the processing instruction, may not be null
target
,
final String
the data contained in the processing instruction, may not be null
data
)

Implements javax.xml.stream.XMLStreamWriter.writeProcessingInstruction.

Writes a processing instruction
public void
public void
writeStartDocument(final String
version of the xml document
version
)

Implements javax.xml.stream.XMLStreamWriter.writeStartDocument.

Write the XML Declaration.
public void
writeStartDocument(final String
encoding of the xml declaration
encoding
,
final String
version of the xml document
version
)

Implements javax.xml.stream.XMLStreamWriter.writeStartDocument.

Write the XML Declaration.
public void
writeStartElement(final String
local name of the tag, may not be null
localName
)

Implements javax.xml.stream.XMLStreamWriter.writeStartElement.

Writes a start tag to the output.
public void
writeStartElement(final String
the namespaceURI of the prefix to use, may not be null
namespaceURI
,
final String
local name of the tag, may not be null
localName
)

Implements javax.xml.stream.XMLStreamWriter.writeStartElement.

Writes a start tag to the output
public void
writeStartElement(final String
the prefix of the tag, may not be null
prefix
,
final String
local name of the tag, may not be null
localName
,
final String
the uri to bind the prefix to, may not be null
namespaceURI
)

Implements javax.xml.stream.XMLStreamWriter.writeStartElement.

Writes a start tag to the output
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

activeelementback to summary
private Element activeelement
activetextback to summary
private Text activetext
boundstackback to summary
private NamespaceStack boundstack
DEFFACback to summary
private static final DefaultJDOMFactory DEFFAC
documentback to summary
private Document document
doneback to summary
private boolean done
factoryback to summary
private final JDOMFactory factory
genprefixback to summary
private int genprefix
globalcontextback to summary
private NamespaceContext globalcontext
isemptyback to summary
private boolean isempty
parentback to summary
private Parent parent
pendingnsback to summary
private LinkedList<Namespace> pendingns
repairnamespaceback to summary
private final boolean repairnamespace
usednsstackback to summary
private NamespaceStack usednsstack

Constructor Detail

StAXStreamWriterback to summary
public StAXStreamWriter()

Create a StAXStreamWriter with the default JDOMFactory for creating JDOM Content.

StAXStreamWriterback to summary
public StAXStreamWriter(final JDOMFactory fac, final boolean repairnamespace)

Create a StAXStreamWriter with the specified JDOMFactory for creating JDOM Content.

Parameters
fac:JDOMFactory

The JDOMFactory to use.

repairnamespace:boolean

If true, then repair namespace errors.

Method Detail

buildAttributeback to summary
private final void buildAttribute(final String prefix, final String namespaceURI, final String localName, final String value, final boolean withpfx) throws XMLStreamException
buildElementback to summary
private final void buildElement(final String prefix, final String localName, final String namespaceURI, final boolean withpfx, boolean empty) throws XMLStreamException

Simple method that implements the empty-element logic without the spec-required null-check logic

Parameters
prefix:String

The namespace prefix (may be null).

localName:String

The Element tag

namespaceURI:String

The namespace URI (may be null).

withpfx:boolean

whether the prefix is user-specified

empty:boolean

Is this an Empty element (expecting children?)

Exceptions
XMLStreamException:
If the stream is not in an appropriate state for a new Element.
closeback to summary
public void close() throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.close.

Doc from javax.xml.stream.XMLStreamWriter.close.

Close this writer and free any resources associated with the writer. This must not close the underlying output stream.

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
flushback to summary
public void flush() throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.flush.

Doc from javax.xml.stream.XMLStreamWriter.flush.

Write any cached data to the underlying output mechanism.

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
flushActiveElementback to summary
private final void flushActiveElement()
flushActiveTextback to summary
private final void flushActiveText()
generatePrefixback to summary
private String generatePrefix()
getDocumentback to summary
public Document getDocument()

Gets the Document that was created by this writer. Only available after writeEndDocument() has been called, and before the Writer is closed.

Returns:Document

The created Document

getNamespaceContextback to summary
public NamespaceContext getNamespaceContext()

Implements javax.xml.stream.XMLStreamWriter.getNamespaceContext.

Doc from javax.xml.stream.XMLStreamWriter.getNamespaceContext.

Returns the current namespace context.

Returns:NamespaceContext

the current NamespaceContext

Annotations
@Override
getPrefixback to summary
public String getPrefix(final String uri) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.getPrefix.

Doc from javax.xml.stream.XMLStreamWriter.getPrefix.

Gets the prefix the uri is bound to.

Parameters
uri:String

the uri the prefix is bound to

Returns:String

the prefix or null

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
getPropertyback to summary
public Object getProperty(String name) throws IllegalArgumentException

Implements javax.xml.stream.XMLStreamWriter.getProperty.

Doc from javax.xml.stream.XMLStreamWriter.getProperty.

Get the value of a feature/property from the underlying implementation

Parameters
name:String

The name of the property, may not be null

Returns:Object

The value of the property

Annotations
@Override
Exceptions
IllegalArgumentException:
if the property is not supported
resolveAttributeNamespaceback to summary
private Namespace resolveAttributeNamespace(String prefix, String namespaceURI, boolean withpfx) throws XMLStreamException
resolveElementNamespaceback to summary
private Namespace resolveElementNamespace(String prefix, String namespaceURI, boolean withpfx) throws XMLStreamException
setDefaultNamespaceback to summary
public void setDefaultNamespace(final String uri) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.setDefaultNamespace.

Doc from javax.xml.stream.XMLStreamWriter.setDefaultNamespace.

Binds a URI to the default namespace This URI is bound in the scope of the current START_ELEMENT / END_ELEMENT pair. If this method is called before a START_ELEMENT has been written the uri is bound in the root scope.

Parameters
uri:String

the uri to bind to the default namespace, may be null

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
setNamespaceContextback to summary
public void setNamespaceContext(final NamespaceContext context) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.setNamespaceContext.

Doc from javax.xml.stream.XMLStreamWriter.setNamespaceContext.

Sets the current namespace context for prefix and uri bindings. This context becomes the root namespace context for writing and will replace the current root namespace context. Subsequent calls to setPrefix and setDefaultNamespace will bind namespaces using the context passed to the method as the root context for resolving namespaces. This method may only be called once at the start of the document. It does not cause the namespaces to be declared. If a namespace URI to prefix mapping is found in the namespace context it is treated as declared and the prefix may be used by the StreamWriter.

Parameters
context:NamespaceContext

the namespace context to use for this writer, may not be null

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
setPrefixback to summary
public void setPrefix(final String prefix, final String uri) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.setPrefix.

Doc from javax.xml.stream.XMLStreamWriter.setPrefix.

Sets the prefix the uri is bound to. This prefix is bound in the scope of the current START_ELEMENT / END_ELEMENT pair. If this method is called before a START_ELEMENT has been written the prefix is bound in the root scope.

Parameters
prefix:String

the prefix to bind to the uri, may not be null

uri:String

the uri to bind to the prefix, may be null

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeAttributeback to summary
public void writeAttribute(final String localName, final String value) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeAttribute.

Doc from javax.xml.stream.XMLStreamWriter.writeAttribute.

Writes an attribute to the output stream without a prefix.

Parameters
localName:String

the local name of the attribute

value:String

the value of the attribute

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeAttributeback to summary
public void writeAttribute(final String namespaceURI, final String localName, final String value) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeAttribute.

Doc from javax.xml.stream.XMLStreamWriter.writeAttribute.

Writes an attribute to the output stream

Parameters
namespaceURI:String

the uri of the prefix for this attribute

localName:String

the local name of the attribute

value:String

the value of the attribute

Annotations
@Override
Exceptions
XMLStreamException:
if the namespace URI has not been bound to a prefix and javax.xml.stream.isRepairingNamespaces has not been set to true
writeAttributeback to summary
public void writeAttribute(final String prefix, final String namespaceURI, final String localName, final String value) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeAttribute.

Doc from javax.xml.stream.XMLStreamWriter.writeAttribute.

Writes an attribute to the output stream

Parameters
prefix:String

the prefix for this attribute

namespaceURI:String

the uri of the prefix for this attribute

localName:String

the local name of the attribute

value:String

the value of the attribute

Annotations
@Override
Exceptions
XMLStreamException:
if the namespace URI has not been bound to a prefix and javax.xml.stream.isRepairingNamespaces has not been set to true
writeCDataback to summary
public void writeCData(final String data) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeCData.

Doc from javax.xml.stream.XMLStreamWriter.writeCData.

Writes a CData section

Parameters
data:String

the data contained in the CData Section, may not be null

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeCharactersback to summary
public void writeCharacters(final String chars) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeCharacters.

Doc from javax.xml.stream.XMLStreamWriter.writeCharacters.

Write text to the output

Parameters
chars:String

the value to write

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeCharactersback to summary
public void writeCharacters(final char[] chars, final int start, final int len) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeCharacters.

Doc from javax.xml.stream.XMLStreamWriter.writeCharacters.

Write text to the output

Parameters
chars:char[]

the value to write

start:int

the starting position in the array

len:int

the number of characters to write

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeCommentback to summary
public void writeComment(final String data) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeComment.

Doc from javax.xml.stream.XMLStreamWriter.writeComment.

Writes an xml comment with the data enclosed

Parameters
data:String

the data contained in the comment, may be null

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeDefaultNamespaceback to summary
public void writeDefaultNamespace(final String namespaceURI) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeDefaultNamespace.

Doc from javax.xml.stream.XMLStreamWriter.writeDefaultNamespace.

Writes the default namespace to the stream

Parameters
namespaceURI:String

the uri to bind the default namespace to

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeDTDback to summary
public void writeDTD(final String dtd) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeDTD.

Doc from javax.xml.stream.XMLStreamWriter.writeDTD.

Write a DTD section. This string represents the entire doctypedecl production from the XML 1.0 specification.

Parameters
dtd:String

the DTD to be written

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeEmptyElementback to summary
public void writeEmptyElement(final String localName) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeEmptyElement.

Doc from javax.xml.stream.XMLStreamWriter.writeEmptyElement.

Writes an empty element tag to the output

Parameters
localName:String

local name of the tag, may not be null

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeEmptyElementback to summary
public void writeEmptyElement(final String namespaceURI, final String localName) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeEmptyElement.

Doc from javax.xml.stream.XMLStreamWriter.writeEmptyElement.

Writes an empty element tag to the output

Parameters
namespaceURI:String

the uri to bind the tag to, may not be null

localName:String

local name of the tag, may not be null

Annotations
@Override
Exceptions
XMLStreamException:
if the namespace URI has not been bound to a prefix and javax.xml.stream.isRepairingNamespaces has not been set to true
writeEmptyElementback to summary
public void writeEmptyElement(final String prefix, final String localName, final String namespaceURI) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeEmptyElement.

Doc from javax.xml.stream.XMLStreamWriter.writeEmptyElement.

Writes an empty element tag to the output

Parameters
prefix:String

the prefix of the tag, may not be null

localName:String

local name of the tag, may not be null

namespaceURI:String

the uri to bind the tag to, may not be null

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeEndDocumentback to summary
public void writeEndDocument() throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeEndDocument.

Doc from javax.xml.stream.XMLStreamWriter.writeEndDocument.

Closes any start tags and writes corresponding end tags.

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeEndElementback to summary
public void writeEndElement() throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeEndElement.

Doc from javax.xml.stream.XMLStreamWriter.writeEndElement.

Writes an end tag to the output relying on the internal state of the writer to determine the prefix and local name of the event.

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeEntityRefback to summary
public void writeEntityRef(final String name) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeEntityRef.

Doc from javax.xml.stream.XMLStreamWriter.writeEntityRef.

Writes an entity reference

Parameters
name:String

the name of the entity

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeNamespaceback to summary
public void writeNamespace(final String prefix, final String namespaceURI) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeNamespace.

Doc from javax.xml.stream.XMLStreamWriter.writeNamespace.

Writes a namespace to the output stream If the prefix argument to this method is the empty string, "xmlns", or null this method will delegate to writeDefaultNamespace

Parameters
prefix:String

the prefix to bind this namespace to

namespaceURI:String

the uri to bind the prefix to

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeProcessingInstructionback to summary
public void writeProcessingInstruction(final String target) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeProcessingInstruction.

Doc from javax.xml.stream.XMLStreamWriter.writeProcessingInstruction.

Writes a processing instruction

Parameters
target:String

the target of the processing instruction, may not be null

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeProcessingInstructionback to summary
public void writeProcessingInstruction(final String target, final String data) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeProcessingInstruction.

Doc from javax.xml.stream.XMLStreamWriter.writeProcessingInstruction.

Writes a processing instruction

Parameters
target:String

the target of the processing instruction, may not be null

data:String

the data contained in the processing instruction, may not be null

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeStartDocumentback to summary
public void writeStartDocument() throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeStartDocument.

Doc from javax.xml.stream.XMLStreamWriter.writeStartDocument.

Write the XML Declaration. Defaults the XML version to 1.0, and the encoding to utf-8

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeStartDocumentback to summary
public void writeStartDocument(final String version) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeStartDocument.

Doc from javax.xml.stream.XMLStreamWriter.writeStartDocument.

Write the XML Declaration. Defaults the XML version to 1.0

Parameters
version:String

version of the xml document

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeStartDocumentback to summary
public void writeStartDocument(final String encoding, final String version) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeStartDocument.

Doc from javax.xml.stream.XMLStreamWriter.writeStartDocument.

Write the XML Declaration. Note that the encoding parameter does not set the actual encoding of the underlying output. That must be set when the instance of the XMLStreamWriter is created using the XMLOutputFactory

Parameters
encoding:String

encoding of the xml declaration

version:String

version of the xml document

Annotations
@Override
Exceptions
XMLStreamException:
If given encoding does not match encoding of the underlying stream
writeStartElementback to summary
public void writeStartElement(final String localName) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeStartElement.

Doc from javax.xml.stream.XMLStreamWriter.writeStartElement.

Writes a start tag to the output. All writeStartElement methods open a new scope in the internal namespace context. Writing the corresponding EndElement causes the scope to be closed.

Parameters
localName:String

local name of the tag, may not be null

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs
writeStartElementback to summary
public void writeStartElement(final String namespaceURI, final String localName) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeStartElement.

Doc from javax.xml.stream.XMLStreamWriter.writeStartElement.

Writes a start tag to the output

Parameters
namespaceURI:String

the namespaceURI of the prefix to use, may not be null

localName:String

local name of the tag, may not be null

Annotations
@Override
Exceptions
XMLStreamException:
if the namespace URI has not been bound to a prefix and javax.xml.stream.isRepairingNamespaces has not been set to true
writeStartElementback to summary
public void writeStartElement(final String prefix, final String localName, final String namespaceURI) throws XMLStreamException

Implements javax.xml.stream.XMLStreamWriter.writeStartElement.

Doc from javax.xml.stream.XMLStreamWriter.writeStartElement.

Writes a start tag to the output

Parameters
prefix:String

the prefix of the tag, may not be null

localName:String

local name of the tag, may not be null

namespaceURI:String

the uri to bind the prefix to, may not be null

Annotations
@Override
Exceptions
XMLStreamException:
if an error occurs