XmlStreamWriter

interface XmlStreamWriter

Defines an interface to serialization of an XML Infoset.

Properties

Link copied to clipboard
abstract val bytes: ByteArray

Gets the byte serialization for this writer. Note that this will call endDocument first, closing all open tags.

Link copied to clipboard
abstract val text: String

Functions

Link copied to clipboard
abstract fun attribute(name: String, value: String?, namespace: String? = null): XmlStreamWriter

Write an attribute. Calls to attribute() MUST follow a call to startTag() immediately. If there is no prefix defined for the given namespace, a prefix will be defined automatically. If namespace is null or empty string no namespace prefix is printed but just name.

Link copied to clipboard
abstract fun endDocument()

Finish writing. All unclosed start tags will be closed and output will be flushed.

Link copied to clipboard
abstract fun endTag(name: String, namespace: String? = null): XmlStreamWriter

Write end tag. Repetition of namespace and name is just for avoiding errors.

Link copied to clipboard
abstract fun namespacePrefix(uri: String, prefix: String? = null)

Set the namespace prefix

Link copied to clipboard
abstract fun startDocument()

Write the XML declaration.

Link copied to clipboard
abstract fun startTag(name: String, namespace: String? = null): XmlStreamWriter

Writes a start tag with the given namespace and name. If there is no prefix defined for the given namespace, a prefix will be defined automatically. The explicit prefixes for namespaces can be established by calling namespacePrefix immediately before this method. If namespace is null no namespace prefix is printed but just name. If namespace is empty string then serializer will make sure that default empty namespace is declared (in XML 1.0 xmlns='') or throw IllegalStateException if default namespace is already bound to non-empty string.

Link copied to clipboard
abstract fun text(text: String): XmlStreamWriter

Writes text, where special XML chars are escaped automatically

Inherited functions

Link copied to clipboard