PlatformXmlWriterBase

abstract class PlatformXmlWriterBase(indentSequence: Iterable<XmlEvent.TextEvent> = emptyList()) : XmlWriter

Base class for platform xml writers. It contains common code.

Inheritors

Constructors

Link copied to clipboard
constructor(indentSequence: Iterable<XmlEvent.TextEvent> = emptyList())

Properties

Link copied to clipboard
abstract val depth: Int

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

Link copied to clipboard
open override var indent: Int

The indentation level to use for autoindenting the output

Link copied to clipboard
Link copied to clipboard
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

Function that collects namespaces not present in the writer

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

Write an attribute.

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

Write a CDATA section

Link copied to clipboard
abstract override fun close()

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

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

Write a comment.

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

Write a document declaration (DTD).

Link copied to clipboard
abstract 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
abstract 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
abstract fun entityRef(text: String)

Write an entity reference

Link copied to clipboard
Link copied to clipboard
abstract fun flush()

Flush all state to the underlying buffer

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

Get the namespace uri the prefix is currently bound to

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

Get a prefix the uri is currently bound to

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

Write ignorable whitespace.

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

Write a namespace declaration attribute.

open fun namespaceAttr(namespacePrefix: CharSequence, namespaceUri: CharSequence)
Link copied to clipboard
abstract fun processingInstruction(text: String)

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

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

Write a processing instruction with the given target and data

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
inline fun <T : XmlSerializable> XmlWriter.serializeAll(iterable: Iterable<T>)
inline fun <T : XmlSerializable> XmlWriter.serializeAll(sequence: Sequence<T>)
Link copied to clipboard
open fun setPrefix(prefix: CharSequence, namespaceUri: CharSequence)

abstract 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: CharSequence?, localName: CharSequence, prefix: CharSequence? = null)
inline fun XmlWriter.smartStartTag(nsUri: CharSequence?, localName: CharSequence, prefix: CharSequence? = null, body: XmlWriter.() -> Unit)

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
abstract fun startDocument(version: String? = null, encoding: String? = null, standalone: Boolean? = null)

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

Link copied to clipboard
abstract 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
abstract 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?)