XmlBufferedWriter

Class that writes xml to a linear buffer of xml events.

Constructors

Link copied to clipboard
constructor(buffer: MutableList<XmlEvent> = mutableListOf())

Properties

Link copied to clipboard

The buffer of all written events.

Link copied to clipboard
open override val depth: Int

The current depth into the tree. The initial depth is 0

Link copied to clipboard
open var indent: Int

The indentation level to use for autoindenting the output

Link copied to clipboard
open override var indentString: String

The indentation string to use for autoindenting the output

Link copied to clipboard

A namespace context that provides access to known namespaces/prefixes at this point in the writer.

Functions

Link copied to clipboard
open override fun attribute(namespace: String?, name: String, prefix: String?, value: String)

Write an attribute.

Link copied to clipboard
open override fun cdsect(text: String)

Write a CDATA section

Link copied to clipboard
open override fun close()

Close the writer. After invoking this the writer is not writable.

Link copied to clipboard
open override fun comment(text: String)

Write a comment.

Link copied to clipboard
open override fun docdecl(text: String)

Write a document declaration (DTD).

Link copied to clipboard
open override fun endDocument()

Close the document. This will do checks, and update the state, but there is no actual content in an xml stream that corresponds to it.

Link copied to clipboard
open override fun endTag(namespace: String?, localName: String, prefix: String?)

Write a closing tag.

Link copied to clipboard
fun XmlWriter.endTag(predelemname: QName)
Link copied to clipboard
open override fun entityRef(text: String)

Write an entity reference

Link copied to clipboard
Link copied to clipboard
open override fun flush()

Flush all state to the underlying buffer

Link copied to clipboard
open override fun getNamespaceUri(prefix: String): String?

Get the namespace uri the prefix is currently bound to

Link copied to clipboard
open override fun getPrefix(namespaceUri: String?): String?

Get a prefix the uri is currently bound to

Link copied to clipboard
open override fun ignorableWhitespace(text: String)

Write ignorable whitespace.

Link copied to clipboard
open override fun namespaceAttr(namespacePrefix: String, namespaceUri: String)
open fun namespaceAttr(namespace: Namespace)

Write a namespace declaration attribute.

Link copied to clipboard
open override fun processingInstruction(text: String)

Write a processing instruction with the given raw content. When using, prefer the version taking two arguments

open override fun processingInstruction(target: String, data: String)

Write a processing instruction with the given target and data

Link copied to clipboard
Link copied to clipboard

Serialize the content of the reader to the writer. This will continue until the reader has no more events. Note that this does not attempt to balance the tags. It will ignore star/end document events, processing instructions and document declarations if the writer has depth>0 (is in an element where such instructions are illegal).

Link copied to clipboard
open override fun setPrefix(prefix: String, namespaceUri: String)

Bind the prefix to the given uri for this element.

Link copied to clipboard
inline fun XmlWriter.smartStartTag(qName: QName, body: XmlWriter.() -> Unit)

Enhanced function for writing start tags, that will attempt to reuse prefixes.

fun XmlWriter.smartStartTag(nsUri: String?, localName: String, prefix: String? = null): String

Enhanced function for writing start tags, that will attempt to reuse prefixes. Rather than use the passed prefix it will look up the prefix for the given namespace, and if present use that. It will also ensure to write the appropriate namespace attribute if needed. If the namespace is the default/null, xml or the xmlns namespace the implementation will be as expected.

inline fun XmlWriter.smartStartTag(nsUri: String?, localName: String, prefix: String? = null, body: XmlWriter.() -> Unit)

Helper function for writing tags that will automatically write the end tag. Otherwise

Link copied to clipboard
open override fun startDocument(version: String?, encoding: String?, standalone: Boolean?)

Start the document. This causes an xml declaration to be generated with the relevant content.

Link copied to clipboard
open override fun startTag(namespace: String?, localName: String, prefix: String?)

Write a start tag. This increases the current depth.

Link copied to clipboard
inline fun XmlWriter.startTag(nsUri: String?, localName: String, prefix: String? = null, body: XmlWriter.() -> Unit)
Link copied to clipboard
open override fun text(text: String)

Write text.

Link copied to clipboard
fun XmlWriter.writeAttribute(name: String, value: Any?)
fun XmlWriter.writeAttribute(name: String, value: Long)
fun XmlWriter.writeAttribute(name: String, value: QName?)
fun XmlWriter.writeAttribute(name: QName, value: String?)
Link copied to clipboard

Write the current event to the writer. Note that for tags/start elements this will write the attributes, but not the children.

Link copied to clipboard
fun XmlWriter.writeElement(missingNamespaces: MutableMap<String, String>?, reader: XmlReader)

Write the entirety of an element content to the writer.

Link copied to clipboard
fun XmlWriter.writeElementContent(missingNamespaces: MutableMap<String, String>?, reader: XmlReader)

Write the child content of the current element in the reader to the output This does not write the container itself

Link copied to clipboard
inline fun <T> XmlWriter.writeListIfNotEmpty(iterable: Iterable<T>, nsUri: String?, localName: String, prefix: String? = null, body: XmlWriter.(T) -> Unit)

Helper function for writing a list only if it contains any element.

Link copied to clipboard
fun XmlWriter.writeSimpleElement(nsUri: String?, localName: String, prefix: String?, value: String?)