The two monolithic XSD content/identity rules only satisfied the OpenAPIKit validation idiom at the wrong granularity: no per-constraint removability, no isolable failing/near-miss tests. Split them into 32 named rules, each finding tagged at its origin and cached per XSDContext so the walk still runs once per document (the #101 decision against duplicating XSD's recursive type resolution still holds). Wired the streaming path's ID/IDREF and identity checks through the same framework instead of calling the validators imperatively, and added the unwrapAndLookup combinator the rule already named as required. Also includes the mandated repo-wide swiftformat/swiftlint pass.
50 lines
1.9 KiB
Swift
50 lines
1.9 KiB
Swift
/// Identifies which decomposed XSD instance-validation rule a finding belongs
|
|
/// to. XSD content validation and identity-constraint validation are each one
|
|
/// interdependent recursive walk (the #101 decision: a child's effective type
|
|
/// is resolved from its parent's content model and position, then rewritten by
|
|
/// `xsi:type` and derivation controls mid-walk, so the constraint categories
|
|
/// cannot be split into independently-invoked walks without either duplicating
|
|
/// the recursion or changing semantics). Tagging every finding at its origin,
|
|
/// instead, lets the walk run once while still exposing each constraint
|
|
/// category as its own named, independently removable, independently testable
|
|
/// ``PureXML/Validation/Validation`` value: see ``XSDFindingsCache``.
|
|
enum XSDRuleToken: String, CaseIterable, Sendable {
|
|
// MARK: Content validity
|
|
|
|
case nilAttributeRequiresNillable
|
|
case nilElementMustBeEmpty
|
|
case nilElementNoFixedConstraint
|
|
case fixedElementNoChildren
|
|
case fixedElementValueMatches
|
|
case emptyContentForbidsChildren
|
|
case simpleContentForbidsChildren
|
|
case simpleContentTypeValid
|
|
case textForbidden
|
|
case wildcardElementUndeclared
|
|
case simpleTypeDisallowedAttribute
|
|
case simpleTypeForbidsChildren
|
|
case simpleTypeValueValid
|
|
case typeReferenceResolves
|
|
case contentModelStructure
|
|
case attributeTypeValid
|
|
case attributeFixedMatches
|
|
case attributeRequiredPresent
|
|
case attributeSingleID
|
|
case attributeDeclaredOrPermitted
|
|
case wildcardAttributeUndeclared
|
|
case wildcardAttributeTypeValid
|
|
case wildcardAttributeFixedMatches
|
|
case xsiTypeSubstitutionValid
|
|
case xsiTypeOverrideResolves
|
|
case idIdrefConsistent
|
|
|
|
// MARK: Identity constraints
|
|
|
|
case identityConstraintXPathsValid
|
|
case identityKeyFieldPresent
|
|
case identityValueUnique
|
|
case identityKeyrefResolves
|
|
case identityFieldCardinality
|
|
case identityFieldMustBeSimple
|
|
}
|