Surface <!ATTLIST> declarations from the parser and validate attributes against them. Reimplemented from the DTD attribute-list spec; no upstream code copied. - DocumentType gains attributeLists (raw ATTLIST bodies per element); the DoctypeScanner captures them and the EventReader plumbs them through. - AttributeListParser parses a body into AttributeDeclaration values (AttributeType: cdata or enumeration; AttributeDefault: required/implied/ fixed/value). - DTDSchema now checks #REQUIRED presence, #FIXED value match (when present), and enumerated-value membership, in addition to content models. - Tokenized types (ID/IDREF/NMTOKEN) parse but are not yet value-enforced. - 5 attribute tests; 75 total.
23 lines
917 B
Swift
23 lines
917 B
Swift
public extension PureXML.Parsing {
|
|
/// What the parser extracted from a `<!DOCTYPE>` internal subset: the
|
|
/// internal general entities and the `<!ELEMENT>` content-model strings.
|
|
/// Empty when no DTD was processed.
|
|
struct DocumentType: Equatable, Sendable {
|
|
public var entities: [String: String]
|
|
public var elementModels: [String: String]
|
|
/// Raw `<!ATTLIST>` bodies keyed by element name (the text between the
|
|
/// element name and `>`, concatenated across multiple declarations).
|
|
public var attributeLists: [String: String]
|
|
|
|
public init(
|
|
entities: [String: String] = [:],
|
|
elementModels: [String: String] = [:],
|
|
attributeLists: [String: String] = [:],
|
|
) {
|
|
self.entities = entities
|
|
self.elementModels = elementModels
|
|
self.attributeLists = attributeLists
|
|
}
|
|
}
|
|
}
|