Complete the structural DTD validation layer. AttributeType now distinguishes the ID family; the validator does a second pass after the structural walk (since an IDREF may point forward to an ID later in the document): - ID-typed attribute values must be unique across the document. - IDREF values must each resolve to a declared ID. - IDREFS values are split on whitespace and each token must resolve. Reimplemented from the DTD ID/IDREF spec; no upstream code copied. 4 tests; 79 total.
17 lines
692 B
Swift
17 lines
692 B
Swift
extension PureXML.Validation {
|
|
/// The declared type of a DTD attribute. Remaining tokenized types (NMTOKEN,
|
|
/// ENTITY, and so on) are treated as unconstrained character data; only an
|
|
/// enumeration constrains the value, 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
|
|
}
|
|
}
|