ddn.data.xml.internal.dtd
Internal: DTD parsing, content model representation, and matching.
This module provides the internal DTD data structures, content model parsing into a tree representation, and content model matching used by the DTD validation pipeline.
This module is not part of the public API and may change at any time.
Types 14
Kind of attribute default declaration.
Attribute type in a DTD.
Covers the standard XML 1.0/1.1 attribute types: CDATA, ID, IDREF, IDREFS, NMTOKEN, NMTOKENS, ENTITY, ENTITIES, NOTATION, and ENUMERATION.
All attribute types are validated during DTD validation. Lexical validity checks use the ASCII subset of the XML Name and Nmtoken productions.
A DTD general entity declaration.
string nameEntity name (without `&` and `;`).string valueReplacement text for internal entities (decoded later).bool isParameterTrue if this is a parameter entity (`%name;`).A DTD element declaration.
This stores a raw content model string for now.
string nameElement name.string contentModelRaw content model (e.g. `EMPTY`, `ANY`, or parenthesized model).A DTD attribute declaration.
string elementNameElement name to which this attribute declaration applies.string nameAttribute name.XmlDtdAttributeType typeAttribute type.string[] enumerationEnumerated values (only meaningful for `ENUMERATION`/`NOTATION`).XmlDtdAttributeDefaultKind defaultKindDefault kind.string defaultValueDefault value (for `DEFAULT`/`FIXED`).A DTD notation declaration.
string nameNotation name.string systemIdOptional system identifier.string publicIdOptional public identifier.A DTD unparsed entity declaration (NDATA).
string nameEntity name.string systemIdOptional system identifier.string publicIdOptional public identifier.string notationNameNotation name referenced by `NDATA`.In-memory representation of a DTD.
Stores entity, element, attribute, notation, and unparsed entity declarations collected from internal and external DTD subsets. Used by the DTD validation pipeline for element model checking, attribute validation, and ID/IDREF consistency enforcement.
private XmlDtdEntityDecl[string] _entitiesprivate XmlDtdElementDecl[string] _elementsprivate XmlDtdNotationDecl[string] _notationsprivate XmlDtdUnparsedEntityDecl[string] _unparsedEntitiesprivate XmlDtdAttributeDecl[][string] _attributesByElementvoid defineEntity(string name, string value, bool isParameter = false) @safeDefines a general entity if not already declared.void defineElement(string name, string contentModel) @safeDefines an element declaration if not already declared.const(XmlDtdElementDecl) * findElement(string name) const @safe nothrowLooks up an element declaration.void defineNotation(string name, string systemId = "", string publicId = "") @safeDefines a notation if not already declared.void defineUnparsedEntity(string name, string systemId, string publicId, string notationName) @safeDefines (or redefines) an unparsed entity.const(XmlDtdUnparsedEntityDecl) * findUnparsedEntity(string name) const @safe nothrowLooks up an unparsed entity.XmlDtdUnparsedEntityDecl[] unparsedEntities() const @safeReturns all unparsed entity declarations in deterministic (name-sorted) order.XmlDtdNotationDecl[] notations() const @safeReturns all notation declarations in deterministic (name-sorted) order.const(XmlDtdAttributeDecl)[] attributeDeclsFor(string elementName) const @safe nothrowReturns attribute declarations for `elementName`.Kind of DTD content model node.
Occurrence indicator for content model nodes.
A parsed DTD content model node.
Represents either a named element or a group (sequence/choice) with an occurrence indicator.
ContentModelKind kindKind of this node.string nameElement name (only meaningful for `ELEMENT` kind).ContentModelNode[] childrenChild nodes (only meaningful for `SEQUENCE`/`CHOICE` kinds).ContentModelOccurrence occurrenceOccurrence indicator.Represents a parsed DTD content model.
This can be EMPTY, ANY, mixed content (#PCDATA-based), or an element-content model.
bool isEmptyTrue if the model is `EMPTY`.bool isAnyTrue if the model is `ANY`.bool isMixedTrue if the model is mixed content (starts with `#PCDATA`).bool[string] mixedElementsFor mixed content, the set of allowed element names (may be empty).ContentModelNode rootFor element-content models, the root of the content model tree.bool validTrue if the model was parsed successfully.string errorMessageError message if parsing failed.Result of content model matching.
bool matchesTrue if the content matches the model.string errorMessageError message if matching failed.Functions 15
ParsedContentModel parseContentModel(string model) @safeParses a DTD content model string into a structured representation.ContentModelMatchResult matchContentModel(
const ref ParsedContentModel model,
const(string)[] childElements,
bool hasText) @safeMatches a sequence of child element names against a parsed content model.bool matchNode(const ref ContentModelNode node, const(string)[] children, ref size_t pos) @safebool matchElement(const ref ContentModelNode node, const(string)[] children, ref size_t pos) @safebool matchSequence(const ref ContentModelNode node, const(string)[] children, ref size_t pos) @safebool matchChoice(const ref ContentModelNode node, const(string)[] children, ref size_t pos) @safebool isNameStartChar(char c) @safe nothrow pureReturns `true` if `c` is an XML 1.0 NameStartChar (ASCII subset).bool isNameCharFull(char c) @safe nothrow pureReturns `true` if `c` is an XML 1.0 NameChar (ASCII subset).bool isValidXmlName(string s) @safe nothrow pureReturns `true` if `s` is a valid XML 1.0 `Name` (ASCII subset).bool isValidNmToken(string s) @safe nothrow pureReturns `true` if `s` is a valid XML 1.0 `Nmtoken` (ASCII subset).