Complete the DTD attribute handling found in the audit: - Default and #FIXED attribute values are applied to the parsed tree. parseApplyingInternalDTDDefaults returns a tree where every element carries the attributes its <!ATTLIST> defaults, so an editor sees the same effective attributes a validating processor would. - NMTOKEN, NMTOKENS, ENTITY, ENTITIES are validated: NMTOKEN(S) must be XML name tokens, ENTITY/ENTITIES must be XML names. Previously all fell through to unconstrained CDATA. - DTD default values are normalized per XML 1.0: character and predefined entity references are expanded, literal whitespace becomes a space, and non-CDATA values are collapsed and trimmed. ENTITY/ENTITIES check name syntax only; that the named entity is a declared unparsed entity is not verified, since NDATA entity tracking is not yet modeled. Closes #73
25 lines
1.0 KiB
Swift
25 lines
1.0 KiB
Swift
extension PureXML.Validation {
|
|
/// The declared type of a DTD attribute. An enumeration constrains the value to
|
|
/// a fixed set; the tokenized types constrain its lexical form (a name token, a
|
|
/// name); and the ID family drives cross-document uniqueness and reference
|
|
/// checks.
|
|
enum AttributeType: Equatable {
|
|
case cdata
|
|
case enumeration([String])
|
|
/// `ID`: the value must be unique across the document.
|
|
case id
|
|
/// `IDREF`: the value must match some declared `ID`.
|
|
case idReference
|
|
/// `IDREFS`: each whitespace-separated value must match some declared `ID`.
|
|
case idReferences
|
|
/// `NMTOKEN`: the value must be a single XML name token.
|
|
case nmToken
|
|
/// `NMTOKENS`: each whitespace-separated value must be a name token.
|
|
case nmTokens
|
|
/// `ENTITY`: the value must be an XML name (naming an unparsed entity).
|
|
case entity
|
|
/// `ENTITIES`: each whitespace-separated value must be a name.
|
|
case entities
|
|
}
|
|
}
|