ddn.data.xml.write

High-level XML serialization / writing entrypoints.

Types 3

Supported output encodings for byte-oriented serialization.

UTF8UTF-8 bytes.
UTF16_LEUTF-16 little-endian bytes.
UTF16_BEUTF-16 big-endian bytes.

Options controlling XML serialization.

These options are part of the stable public API.

Fields
XmlOutputEncoding outputEncodingOutput encoding for byte-oriented serialization.
bool emitBomWhether to emit a BOM when `outputEncoding` is UTF-16.
bool prettyIf `true`, the writer may add indentation and newlines.
string indentationIndentation string used when `pretty` is enabled.
string newlineNewline string used when `pretty` is enabled.
bool omitDeclarationIf `true`, omit the XML declaration (e.g. `<?xml version=...?>`).

Streaming XML writer that can generate XML without building a DOM.

This is useful for large documents.

Fields
private XmlWriteOptions _options
private void delegate(const(char)[]) @safe _charSink
private void delegate(const(ubyte)[]) @safe _byteSink
private typeof(appender!string()) _internalSink
private string[] _stack
private bool _startTagOpen
private bool _finished
private bool[] _hasTextChild
private bool[] _hasElementChild
private string[string][] _nsStack
private size_t _nsCounter
private AttrName[] _currentAttributes
Methods
private void initWriter() @safe
private void writeRaw(const(char)[] s) @safe
void startElement(string qname) @safeStarts an element.
void declareNamespace(string prefix, string uri) @safeDeclares a namespace on the currently open start tag.
void startElementNS(string namespaceUri, string local, string prefix = "") @safeStarts an element using a namespace URI and local name.
void attributeNS(string namespaceUri, string local, string prefix, string value) @safeWrites a namespace-qualified attribute.
void attribute(string qname, string value) @safeWrites an attribute on the currently open start tag.
private void checkDuplicateAttr(string uri, string local) @safe
void text(string value) @safeWrites text content.
void comment(string value) @safeWrites a comment.
void processingInstruction(string target, string data = "") @safeWrites a processing instruction.
void endElement() @safeEnds the current element.
string finish() @safeFinishes the document and returns the accumulated output.
void ensureNotFinished() @safe
void writeIndent(size_t depth) @safe
string lookupUri(string prefix) const @safe nothrow
Constructors
this(XmlWriteOptions options = XmlWriteOptions.init)Constructs a new streaming writer using an internal buffer.
this(void delegate(const(char)[]) @safe sink, XmlWriteOptions options = XmlWriteOptions.init)Constructs a new streaming writer using a character sink.
this(void delegate(const(ubyte)[]) @safe sink, XmlWriteOptions options = XmlWriteOptions.init)Constructs a new streaming writer using a byte sink.
Nested Templates
AttrName

Functions 10

private fnXmlInternalWriteOptions toInternalOptions(const XmlWriteOptions options) @safe nothrow
fnstring toXmlString(XmlNode node, XmlWriteOptions options = XmlWriteOptions.init) @safeSerializes a DOM node to an XML string.
fnstring writeXml(XmlDocument document, XmlWriteOptions options = XmlWriteOptions.init) @safeSerializes a document to an XML string.
fnvoid writeXmlTo(R)(ref R sink, XmlNode node, XmlWriteOptions options = XmlWriteOptions.init) if (isOutputRange!(R, char))Writes XML to an output range.
fnubyte[] toXmlBytes(XmlNode node, XmlWriteOptions options = XmlWriteOptions.init) @safeSerializes a DOM node to raw bytes according to `options.outputEncoding`.
fnubyte[] writeXmlBytes(XmlDocument document, XmlWriteOptions options = XmlWriteOptions.init) @safeSerializes a document to raw bytes.
fnstring serialize(XmlNode node, XmlWriteOptions options = XmlWriteOptions.init) @safeSerializes a DOM node to an XML string.
fnstring pretty(XmlNode node, string indent = " ") @safeSerializes a DOM node to a pretty-printed XML string.
private fnubyte[] encodeUtf16(string utf8, bool littleEndian, bool emitBom) @safe
private fnubyte[] toUTF16Bytes(const(char)[] s, bool littleEndian) @safe