Package-level declarations

Core package for a wrapper that provides XML pull parsing access. Note that the implementations may do some adjustments beyond what is provided by the underlying implementation to improve compatibility across platforms. The access point to the package/module is (XmlStreaming)nl.adaptivity.xml.XmlStreaming.

Core package for a wrapper that provides XML pull parsing access. Note that the implementations may do some adjustments beyond what is provided by the underlying implementation to improve compatibility across platforms. The access point to the package/module is (XmlStreaming)nl.adaptivity.xml.XmlStreaming.

Core package for a wrapper that provides XML pull parsing access. Note that the implementations may do some adjustments beyond what is provided by the underlying implementation to improve compatibility across platforms. The access point to the package/module is (XmlStreaming)nl.adaptivity.xml.XmlStreaming.

Core package for a wrapper that provides XML pull parsing access. Note that the implementations may do some adjustments beyond what is provided by the underlying implementation to improve compatibility across platforms. The access point to the package/module is (XmlStreaming)nl.adaptivity.xml.XmlStreaming.

Types

Link copied to clipboard

Writer that uses the DOM for the underlying storage (rather than writing to some string).

Link copied to clipboard

Enum representing the type of an xml node/event.

Link copied to clipboard

Annotation to signify that the annotated code is experimental, with limited compatibility support.

Link copied to clipboard

Namespace context that allows iterating over the namespaces.

Link copied to clipboard
interface IXmlStreaming

IXMLStreaming is the interface (accessible through xmlStreaming) that exposes the XML parsing and serialization in a platform independent way.

Link copied to clipboard
interface Namespace

Interface that represents a namespace with prefix and uri.

Link copied to clipboard
actual interface NamespaceContext

Interface that provides access to namespace queries

expect interface NamespaceContext

Interface that provides access to namespace queries

actual interface NamespaceContext

Interface that provides access to namespace queries

Link copied to clipboard
actual class QName(namespaceURI: String, localPart: String, prefix: String)
expect class QName(namespaceURI: String, localPart: String, prefix: String)

Platform independent implementation of QName

actual class QName(namespaceURI: String, localPart: String, prefix: String)
actual typealias QName = javax.xml.namespace.QName

Use the native QName type.

Link copied to clipboard

Serializer for QNames that allows writing in XML context to be as prefix:localPart where the namespace declaration is added when needed.

Link copied to clipboard

Shortcut alias for QName that associates the QNameSerializer with the type. Note that the QNameSerializer has special features for the XML format.

Link copied to clipboard

An xml reader that has a buffer that allows peeking events as well as injecting events into the stream. Note that this class does not do any validation of the xml. If injecting/removing elements into/from the buffer you can create invalid XML.

Link copied to clipboard

Base class for XML readers that support buffering of the parsing results.

Link copied to clipboard

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

Link copied to clipboard

A reader that presents a list of events as an xml reader. This is designed to work together with XmlBufferedWriter.

Link copied to clipboard

Various namespace constants and their corresponding default prefixes.

Link copied to clipboard

Mode to use for writing the XML Declaration.

Link copied to clipboard
open class XmlDelegatingReader(val delegate: XmlReader) : XmlReader

Simple baseclass for a delating XmlReader. It merely functions as a delegate. With Kotlin it's not really needed, but nice.

Link copied to clipboard
abstract class XmlDelegatingWriter(val delegate: XmlWriter) : XmlWriter

Simple delegating writer that passes all calls on to the delegate. This class is abstract for the only reason that any direct instances of this class make little sense.

Link copied to clipboard

DeserializationStrategy sub-interface that supports special deserialization for the XML format. The format will call deserializeXML rather than deserialize allowing for special functionality.

Link copied to clipboard

Marker (only relevant to custom serializers) that signifies that serialization will contain custom QNames that can be collected when isCollectingNSAttributes is set to true.

Link copied to clipboard
sealed class XmlEvent(val extLocationInfo: XmlReader.LocationInfo?)

A class to represent the events that can occur in XML Documents

Link copied to clipboard
open class XmlException : IOException

Simple exception for xml related things.

Link copied to clipboard

XmlReader that supports at least lightweight peeking. This could be full buffering, or being able to "undo" the next function so that calling it again will give the same result. Note that the implementation may not allow for inspecting the event in pushed back state.

Link copied to clipboard
interface XmlReader : Closeable, Iterator<EventType>

Interface that is the entry point to the xml parsing. All implementations implement this interface, generally by delegating to a platform specific parser.

Link copied to clipboard

Serial Descriptor delegate that supports special casing by the XML format. This means that the descriptor can be different for non-xml and xml serialization. (Used by the QName serializer).

Link copied to clipboard

Marker to signify that the descriptor is an xmlSerialDescriptor and the delegate can be retrieved through getElementDescriptor with negative value.

Link copied to clipboard

SerializationStrategy sub-interface that supports special serialization for the XML format. The format will call serializeXML rather than serialize allowing for special functionality.

Link copied to clipboard

Combined interface for custom serializers that support special casing by the XML Format.

Link copied to clipboard
expect interface XmlStreamingFactory

A factory that can be used to customize xmlStreaming to use these custom factory functions when not using the explicit generic implementations.

actual interface XmlStreamingFactory

A factory that can be used to customize xmlStreaming to use these custom factory functions when not using the explicit generic implementations. Factories are picked up using service loaders.

Link copied to clipboard

Annotation to signify that the annotated code is internal to the XmlUtil module, and no API stability is guaranteed.

Link copied to clipboard

Annotation to signify that the annotated code is internal to the XmlUtil module, and no API stability is guaranteed.

Link copied to clipboard
interface XmlWriter : Closeable

Interface representing the (wrapper) type that allows generating xml documents.

Properties

Link copied to clipboard

Get a range for the attributes in the reader

Link copied to clipboard

Get an array of all attributes in the current (startTag) event.

Link copied to clipboard

Get a streaming factory that returns the platform independent serializer/deserializer implementations.

Link copied to clipboard

Property syntax accessor for QName.getLocalPart

Link copied to clipboard

Property syntax accessor for QName.getNamespaceURI

Link copied to clipboard

Property syntax accessor for QName.getPrefix

Link copied to clipboard

Read a QName text from the reader. This will read prefix:localName values and resolve the namespace.

Link copied to clipboard

Retrieve a platform independent accessor to create Streaming XML parsing objects

Retrieve a platform independent accessor to create Streaming XML parsing objects

Retrieve a platform independent accessor to create Streaming XML parsing objects

Retrieve a platform independent accessor to create Streaming XML parsing objects

Functions

Link copied to clipboard

Consume all text and non-content (comment/processing instruction) to get an uninterrupted text sequence. This will skip over comments but not ignorable whitespace that starts the string, but not tags. Any tags encountered will lead to a return of this function. Any tags encountered with cause an exception to be thrown. It can either be invoked when in a start tag to return all text content, or on a content element to include it (if text or cdata) and all subsequent siblings.

Link copied to clipboard

Get the next text sequence in the reader. This will skip over comments and ignorable whitespace (starting the content), but not tags. Any tags encountered with cause an exception to be thrown. It can either be invoked when in a start tag to return all text content, or on a content element to include it (if text or cdata) and all subsequent siblings.

Link copied to clipboard

Convert a prefixed element name (CNAME) to a qname. If there is no prefix, the default prefix is used.

Link copied to clipboard

Create a new reader that only returns the current element and its descendents. Such sub-reader ensures that the user of the return value does not exceed this stream.

Link copied to clipboard

Consume all text and non-content (comment/processing instruction) to get an uninterrupted text sequence. This will skip over comments and ignorable whitespace that starts the string, but not tags. Any tags encountered will lead to a return of this function. Any tags encountered with cause an exception to be thrown. It can either be invoked when in a start tag to return all text content, or on a content element to include it (if text or cdata) and all subsequent siblings.

Link copied to clipboard

Differs from .siblingsToFragment in that it skips the current event.

Link copied to clipboard

Read the current element (and content) only into a fragment.

Link copied to clipboard
fun XmlWriter.endTag(predelemname: QName)

Write an end tag event.

Link copied to clipboard

Create a writer that wraps a substream ensuring that document level events are ignored.

Link copied to clipboard
fun XmlReader.isElement(elementname: QName): Boolean

Determine whether the current event of the XMLReader is an element with the given name. Note that this ignores the prefix of the name.

fun XmlReader.isElement(type: EventType, elementname: QName): Boolean
fun XmlReader.isElement(elementNamespace: String?, elementName: String, elementPrefix: String? = null): Boolean
fun XmlReader.isElement(type: EventType, elementNamespace: String?, elementName: String, elementPrefix: String? = null): Boolean

Check that the current state is a start element for the given name. The mPrefix is ignored.

Link copied to clipboard
infix fun QName.isEquivalent(other: QName): Boolean

Determine whether two QNames are equivalent (the prefix is ignored, the others compared textually).

Link copied to clipboard

Determine whether the two QNames are fully equal

Link copied to clipboard

Determine whether the current event in the reader is ignorable. This ignores: comments, start/end document, processing instructions, document declarations, ignorable whitespace, and text that is effectively xml whitespace.

Link copied to clipboard

Determine whether the given prefix is known in the reader (up to this point). This can be used for reading text that could reference a namespace prefix (e.g. when parsing XPath expressions).

Link copied to clipboard

Determine whether the character is XML whitespace.

Determine whether all the characters in the array are XML Whitespace.

Determine whether all the characters in the sequence are XML Whitespace.

Link copied to clipboard

Create a new XML reader with the given source node as starting point. This reader is generic.

Create a new XML reader with the given source node as starting point. This reader is generic. This would does charset detection using BOM for UTF variants and the xml declaration.

Link copied to clipboard
fun IXmlStreaming.newGenericWriter(output: Appendable, isRepairNamespaces: Boolean = false, xmlDeclMode: XmlDeclMode = XmlDeclMode.None): KtXmlWriter

Create a new XmlWriter that appends to the given Appendable. This writer could be a platform specific writer.

Link copied to clipboard

Create a new XML reader with the given source node as starting point. Depending on the configuration, this parser can be platform specific.

Create a new XML reader with the given source node as starting point. Depending on the configuration, this parser can be platform specific. This would normally do some level of charset detection (e.g. using the xml declaration, a.o. UTF BOM based detection).

fun IXmlStreaming.newReader(inputStream: InputStream, encoding: String): XmlReader

Create a new XML reader with the given source node as starting point. Depending on the configuration, this parser can be platform specific.

Link copied to clipboard
actual fun IXmlStreaming.newWriter(output: Appendable, repairNamespaces: Boolean, xmlDeclMode: XmlDeclMode): XmlWriter

Create a new XmlWriter that appends to the given Appendable.

actual fun IXmlStreaming.newWriter(writer: Writer, repairNamespaces: Boolean, xmlDeclMode: XmlDeclMode): XmlWriter

Create a new XmlWriter that appends to the given Writer. This writer could be a platform specific writer.

expect fun IXmlStreaming.newWriter(output: Appendable, repairNamespaces: Boolean = false, xmlDeclMode: XmlDeclMode = XmlDeclMode.None): XmlWriter

Create a new XmlWriter that appends to the given Appendable. This writer could be a platform specific writer.

expect fun IXmlStreaming.newWriter(writer: Writer, repairNamespaces: Boolean = false, xmlDeclMode: XmlDeclMode = XmlDeclMode.None): XmlWriter

Create a new XmlWriter that appends to the given Writer. This writer could be a platform specific writer.

Create a new DomWriter that results in writing to DOM with dest as the receiver node.

actual fun IXmlStreaming.newWriter(output: Appendable, repairNamespaces: Boolean, xmlDeclMode: XmlDeclMode): XmlWriter

Create a new XmlWriter that appends to the given Appendable. This writer could be a platform specific writer.

actual fun IXmlStreaming.newWriter(writer: Writer, repairNamespaces: Boolean, xmlDeclMode: XmlDeclMode): XmlWriter

Create a new XmlWriter that appends to the given Writer. This writer could be a platform specific writer.

fun IXmlStreaming.newWriter(outputStream: OutputStream, encoding: String, repairNamespaces: Boolean = false): XmlWriter

Create a new XmlWriter that appends to the given OutputStream. This writer could be a platform specific writer.

fun IXmlStreaming.newWriter(writer: Writer, repairNamespaces: Boolean = false, xmlDeclMode: XmlDeclMode = XmlDeclMode.None): XmlWriter

Create a new XmlWriter that appends to the given java specific java.io.Writer.

actual fun IXmlStreaming.newWriter(output: Appendable, repairNamespaces: Boolean, xmlDeclMode: XmlDeclMode): XmlWriter

Create a new XmlWriter that appends to the given Writer. This writer could be a platform specific writer.

actual fun IXmlStreaming.newWriter(writer: Writer, repairNamespaces: Boolean, xmlDeclMode: XmlDeclMode): XmlWriter

Create a new XmlWriter that appends to the given multi-platform MPWriter.

Link copied to clipboard
fun qname(namespaceUri: String?, localname: String, prefix: String? = DEFAULT_NS_PREFIX): QName

Shorthand function to create a QName.

Link copied to clipboard

From a start tag read the text only content of the element. Comments are allowed and handled, but subtags are not allowed. This tag finishes at the end of the element.

Link copied to clipboard

Helper to write the given node to the xml writer.

fun XmlWriter.serialize(reader: XmlReader, keepDuplicatedNsDecls: Boolean = true)

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).

Write the node to the writer

Link copied to clipboard

Set the factory that is used to initialise the non-generic readers/writers.

Link copied to clipboard

Read the current event and all subsequent siblings into a compact fragment.

Link copied to clipboard

From a start element, skip all element content until the corresponding end element has been read. After invocation the end element has just been read (and would be returned on relevant state calls).

Link copied to clipboard

Skil the preamble events in the stream reader

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.

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 uses the version that does not take a body parameter.

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

Helper function for a tag that allows writing the body but closes the tag on completion.

Link copied to clipboard

Write all the remaining content of the reader to a CharArrayWriter. Note that this likely fails if the reader is not at the start (as the writer would fail due to an invalid XML document).

Link copied to clipboard

Get the CName part of a QName

Link copied to clipboard

Create an XmlEvent for the current event in an XmlReader.

Link copied to clipboard

Extract the namespace for the QName (excluding the local name)

Link copied to clipboard

Convert the string as fqn literal to an actual qname. The formats handled are:

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?)

Write an attribute (must be in tag writing state - no content written yet).

Link copied to clipboard

Write the current event to the writer. This will not move the reader.

Link copied to clipboard
fun XmlWriter.writeCurrentEvent(reader: XmlReader, keepDuplicatedNsDecls: Boolean = true)

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?)

Helper function that writes a simple element without attributes and a simple value.

Link copied to clipboard
fun SerialDescriptor.xml(xmlDescriptor: SerialDescriptor = this, serialQName: QName? = null): XmlSerialDescriptor

Helper function that allows the XML format to use a different descriptor for the given type. This is intended for use with custom serializers implementing XmlSerializer to handle xml serialization specially.

Link copied to clipboard

Implementation of the XMLSchema whitespace collapsing algorithm. This involves:

Link copied to clipboard

Encode the text such that it escapes the '<', '>', and '&' characters. This does not encode quotation characters (as would be needed in attributes).

Link copied to clipboard

Implementation of the XML whitespace trimming algorithm. Unlike xmlCollapseWhitespace this function does not collapse multi-whitespace sequences, but still normalizes to space, and trims start and end.