public extension PureXML.Validation { /// A DTD schema: the element content models declared by `` and the /// attribute declarations from ``, against which a parsed tree can /// be validated. Built from the internal subset surfaced by the parser. struct DTDSchema: Sendable { let models: [String: ContentModel] let attributes: [String: [AttributeDeclaration]] /// The names declared by ``, against which a `NOTATION` attribute /// value (and the names listed in its declaration) are checked. let notations: Set /// The names of declared unparsed (`NDATA`) entities, against which an /// `ENTITY`/`ENTITIES` attribute value is checked. let unparsedEntities: Set init(_ documentType: PureXML.Parsing.DocumentType) { notations = Set(documentType.notations.keys) unparsedEntities = Set(documentType.unparsedEntities.keys) var parsedModels: [String: ContentModel] = [:] for (name, model) in documentType.elementModels { parsedModels[name] = ContentModelParser.parse(model) } models = parsedModels var parsedAttributes: [String: [AttributeDeclaration]] = [:] for (name, body) in documentType.attributeLists { parsedAttributes[name] = AttributeListParser.parse(body) } attributes = parsedAttributes } /// Whether the schema declares any elements or attributes. public var isEmpty: Bool { models.isEmpty && attributes.isEmpty } } }