ddn.data.xml.stream
Streaming (pull) parsing and event model entrypoints.
Types 5
Status codes for the incremental streaming reader (XmlIncrementalReader).
The reader is always in exactly one of these states:
NEED_MORE_DATA— no event is available; the caller mustfeed()more bytes.READY— an event is available viafront().END_OF_STREAM—markEndOfStream()was called and all input has been consumed.
END_OF_STREAM is terminal: once entered, no further operation changes the status. READY is transient: a subsequent advance() transitions to one of the other states.
Options controlling XmlReader behavior.
bool substituteEntitiesIf `true`, decode entity references in text and attribute values.bool forbidDoctypeIf `true`, reject `DOCTYPE` declarations.A pull-style streaming XML reader.
The reader is an input range over XmlEvent.
private XmlLexer _lexerprivate XmlParserLimits _limitsprivate XmlEvent _frontprivate bool _emptyprivate XmlReaderOptions _optionsprivate TokenProcessingState _stateprivate size_t _attributeIndexbool isEmptyElement() @property const @safe nothrowReturns `true` if the current event is a `START_ELEMENT` for an empty element.bool onAttribute() @property const @safe nothrowReturns `true` if the reader is positioned on an attribute of the current `START_ELEMENT`.bool moveToFirstAttribute() @safe nothrowMoves to the first attribute on the current `START_ELEMENT`.string readString() @safeReturns the string value of the current event's content. If on STARTELEMENT, it reads until matching ENDELEMENT and returns concatenated text.void writeEvent(XmlStreamWriter writer, ref const(XmlEvent) ev) @safeconst(XmlEventAttribute) attribute() @property ref const @safe nothrowReturns the current attribute.string name() @property const @safe nothrowReturns the current node name (`prefix:local` or `local`).size_t attributeCount() @property const @safe nothrowReturns the attribute count for the current `START_ELEMENT`.string getAttributeNS(string uri, string localName) const @safe nothrowLooks up an attribute value by expanded name `{namespaceUri, local}`.bool moveToAttributeNS(string uri, string localName) @safe nothrowMoves to an attribute by expanded name `{namespaceUri, local}`.void advance() @safethis()this(
string input,
string systemId = "",
size_t maxExpandedBytes = 0,
XmlReaderOptions options = XmlReaderOptions.init)Constructs a reader over `input`.Options controlling XmlIncrementalReader behavior.
bool substituteEntitiesIf `true`, decode entity references in text and attribute values.bool forbidDoctypeIf `true`, reject `DOCTYPE` declarations.An incremental (streaming) pull-style XML reader that accepts data in chunks.
Unlike XmlReader, which requires the entire XML input up front, this reader maintains an internal growable buffer and supports the feed() / compact() / markEndOfStream() lifecycle required for streaming parsing.
The reader operates as an explicit pump loop:
auto reader = new XmlIncrementalReader();
while (reader.status() == XmlStreamStatus.NEED_MORE_DATA) {
auto chunk = socket.receive(buffer[]);
if (chunk.length == 0) { reader.markEndOfStream(); break; }
reader.feed(chunk);
while (reader.advance() == XmlStreamStatus.READY) {
processEvent(reader.front());
}
}Ownership: Every string field in XmlEvent and its sub-fields is owned
storage, not a slice into the internal buffer. Event strings remain valid until the reader is destroyed. compact() and feed() do not invalidate previously returned event strings.
NEED_MORE_DATA— no event available; caller mustfeed()more bytes.READY— an event is available viafront().END_OF_STREAM— terminal;markEndOfStream()was called and all input
has been consumed.
ForwardRange / save() are explicitly excluded from the initial release.
private XmlIncrementalLexer _lexerprivate XmlParserLimits _limitsprivate XmlEvent _frontprivate XmlStreamStatus _statusprivate bool _eosprivate XmlIncrementalReaderOptions _optionsprivate TokenProcessingState _statevoid compact() @safe pure nothrowMoves unread bytes to the front of the internal buffer to reclaim space.bool isEmptyElement() @property const @safe nothrowReturns `true` if the current event is a `START_ELEMENT` for an empty element.this(string systemId = "",
XmlIncrementalReaderOptions options = XmlIncrementalReaderOptions.init)Constructs an incremental reader.