PureXML/Sources/Schema/XSDFindingsCache.swift
Mihaela Mihaljevic 380160cc2b refactor(validation): decompose XSD instance validation into composable rules
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.
2026-07-12 14:12:17 +02:00

13 lines
696 B
Swift

/// Memoizes the one full tagged content-validity walk, and the one full tagged
/// identity-constraint walk, per ``PureXML/Validation/XSDContext`` instance.
/// Each decomposed rule's `check` reads this cache (computing it on first use)
/// and filters by its own token, so registering the whole decomposed rule set
/// together still walks the tree exactly once, not once per rule. A fresh
/// `XSDContext` (built once per top-level `validate` call, see
/// `SchemaDocument.validate(_:)`) gets a fresh cache, so there is no staleness
/// risk across documents.
final class XSDFindingsCache: @unchecked Sendable {
var contentFindings: [XSDFinding]?
var identityFindings: [XSDFinding]?
}