ddn.data.xml.internal.tokens
Internal: shared token-processing state and helpers.
This module provides reusable logic extracted from XmlReader.advance() and parseSax(). It is designed to support both the existing pull reader and the planned incremental reader without duplicating namespace resolution, element stack management, or event construction code.
This module is not part of the public API and may change at any time.
struct TokenProcessingState
Types 1
structTokenProcessingState
Shared mutable state for token-to-event processing.
Holds the element stack, namespace stack, and pending end-element state used by both the existing XmlReader and the planned incremental reader to track document structure across tokens.
The struct is intended to be used by value or by reference. Stack operations mutate the struct in place.
Fields
string[] elementStackElement name stack. Pushed on non-empty start tags, popped on end tags. The stack length equals the current nesting depth.string[string][] nsStackNamespace scope stack. Each entry maps prefixes to namespace URIs declared in that scope. Scopes are pushed on start tags and popped on matching end tags (or immediately for empty elements).string pendingEndNamePending end-element name for empty-element tags (`<a/>`).XmlLocation pendingEndLocationLocation of the pending end-element event.string pendingEndPrefixPrefix part of the pending end-element name.string pendingEndLocalLocal part of the pending end-element name.string pendingEndNamespaceUriNamespace URI of the pending end-element.size_t pendingEndDepthDepth at which the pending end-element was opened.Methods
bool hasPendingEnd() const @safe pure nothrowReturns `true` when a synthetic `END_ELEMENT` is pending.string lookupNamespaceUri(string prefix) const @safe nothrowLooks up a namespace URI for the given prefix.Functions 12
fn
void splitQName(string qname, out string prefix, out string local) @safe pure nothrowSplits a QName into its prefix and local parts.fn
string[string] extractNamespaceDeclarations(
const XmlTokenAttribute[] attributes,
bool decodeEntities,
bool normalizeValues,
const ref XmlParserLimits limits) @safeExtracts namespace declarations from a set of token attributes.fn
string resolveAttributeUri(
string attrName,
string attrPrefix,
const string[string][] nsStack) @safe nothrowResolves the namespace URI for an attribute name.fn
XmlEvent buildStartTagEvent(
ref TokenProcessingState state,
const XmlToken tok,
bool decodeEntities,
bool normalizeValues,
const ref XmlParserLimits limits) @safeProcesses a `START_TAG` token and returns the corresponding `XmlEvent`.fn
XmlEvent buildEndTagEvent(
ref TokenProcessingState state,
const XmlToken tok) @safe nothrowProcesses an `END_TAG` token and returns the corresponding `XmlEvent`.fn
XmlEvent buildPendingEndEvent(ref TokenProcessingState state) @safe pure nothrowReturns the pending `END_ELEMENT` event and clears the pending state.fn
XmlEvent buildTextEvent(
ref TokenProcessingState state,
const XmlToken tok,
bool decodeEntities,
const ref XmlParserLimits limits) @safeBuilds a `TEXT` event from a token.fn
XmlEvent buildCommentEvent(
const ref TokenProcessingState state,
const XmlToken tok) @safe pure nothrowBuilds a `COMMENT` event from a token.fn
XmlEvent buildCDataEvent(
const ref TokenProcessingState state,
const XmlToken tok) @safe pure nothrowBuilds a `CDATA` event from a token.fn
XmlEvent buildPIEvent(
const ref TokenProcessingState state,
const XmlToken tok) @safe nothrowBuilds a `PROCESSING_INSTRUCTION` event from a token.fn
XmlEvent buildDoctypeEvent(
const ref TokenProcessingState state,
const XmlToken tok) @safe pure nothrowBuilds a `DOCTYPE` event from a token.