NameAndTypeOK clause 1 (XSD 1.0 section 3.9.6, Elt:Elt) pairs the declared
element declarations and requires the same {name} and {target namespace};
no clause grants substitution an allowance. The substitution-group
expansion rewrites the compiled term (an abstract head is dropped, members
join a synthetic choice), so the checker previously compared the expanded
names and a head-for-member swap looked name-identical.
Particle.declaredReference now preserves the pre-expansion identity of an
element-ref particle, and the restriction check pairs the declared
references before the structural pairing table (extracted as
structuralValid). Closes XSTS elemZ026 and particlesV020:
invalid-schemas-accepted 8 -> 6, valid buckets unchanged at zero.
Stricter than libxml2, which does not implement this edge; elemZ026 is
pinned in the differential baseline accordingly.
particlesZ008, byte-for-byte the same construct as elemZ026 but carrying
a settled valid expectation contradicting elemZ026's settled invalid, is
reclassified as a spec-divergent schema test with the adjudication
recorded in the suite (exclusion tables split into
Tests/XSTSSuiteExclusions.swift for file length).
Separately attributed: the differential baseline gains ten further pinned
entries (addB070a, addB108, addB177, attO025, elemZ027_c, errC008,
groupH021v, notatB005, notatE002, particlesEb040) that reproduce with
this change stashed. They are pre-existing drift from earlier main-line
fixes, not effects of this commit. Baseline 231 -> 242, differential
green.
86 lines
5.9 KiB
Swift
86 lines
5.9 KiB
Swift
import Testing
|
|
@testable import PureXML
|
|
|
|
/// The suite exclusions: tests whose expected validity is not authoritative,
|
|
/// mirroring how the suite's own `status="queried"` entries are skipped. Kept in
|
|
/// their own file so each entry's spec-grounded justification has room to be full.
|
|
extension XSTSSuiteTests {
|
|
/// Instance tests excluded from the counts because their expected validity is not
|
|
/// authoritative, mirroring how the suite's own `status="queried"` entries are
|
|
/// skipped. Each must carry a spec-grounded justification; this is never a place to
|
|
/// hide a real deviation.
|
|
///
|
|
/// - `anyURI_a004_1339.i`: the suite pairs a `valid` schemaTest with an `invalid`
|
|
/// instanceTest, but the two are mutually inconsistent. The schema's `include`,
|
|
/// `import`, and `redefine` have unresolvable schemaLocations; XSD 1.0 §4.2.1
|
|
/// makes an unresolvable `include` "not an error" (no inclusion performed), the
|
|
/// `import` likewise, and the empty `redefine` imposes no resolution requirement
|
|
/// (`src-redefine` clause 1 gates that on non-annotation children), so the schema
|
|
/// is conformantly valid (agreeing with the schemaTest). The only components the
|
|
/// instance exercises (`root`, `bar`, `st`, `att`) are fully locally defined, and
|
|
/// every instance value is byte-identical to one of the type's six anyURI
|
|
/// `enumeration` members, so a strict assessment of the document element is
|
|
/// valid. There is no spec path to valid-schema + invalid-instance. Confirmed by
|
|
/// two independent adversarial analyses; libxml2 is no authority here (it
|
|
/// non-conformantly fails to compile the schema on the unresolvable include).
|
|
/// Matching the suite would mean rejecting a valid instance whenever an include
|
|
/// cannot be resolved, a false positive an IDE editing loop hits constantly.
|
|
///
|
|
/// - `schA2.i`, `schA5.i`: schema-location precedence. Each group's documentation
|
|
/// states the inline `xsi:schemaLocation` hint "is ignored" and the instance
|
|
/// "must conform to" the collection schema, but under exactly that prescribed
|
|
/// behavior the instances are valid (libxml2 validates schA2.xml against its
|
|
/// `a.xsd`, and schA5.xml against its `a.xsd`+`b.xsd` collection), so the
|
|
/// `invalid` expectation contradicts the group's own documentation. Reaching
|
|
/// `invalid` requires letting the instance's hint override a schema already
|
|
/// loaded for that namespace, which XSD 1.0 §4.3.2 makes optional (strategy 1:
|
|
/// "do nothing ... because a schema ... is already known") and which would be a
|
|
/// direct false positive for an IDE (an instance file forcing rejection against
|
|
/// the project's own schema). PureXML's policy (honor hints but keep the
|
|
/// collection's declarations on conflict) is conformant. Confirmed by an
|
|
/// adversarial analysis that separated these from schA7.i, whose `invalid` IS
|
|
/// spec-grounded (a genuine policy deviation, left in the count).
|
|
///
|
|
/// - `mgO013.i`: a `redefine` whose group `all{e1(1,1)}` redefines a base
|
|
/// `all{e1(0,0)}` without referencing itself. `src-redefine` clause 6.2.2 makes
|
|
/// that a restriction obligation, and `all{e1(1,1)}` is not a valid restriction
|
|
/// of `all{e1(0,0)}` (Occurrence Range OK: derived max 1 > base max 0), so
|
|
/// enforcing it rejects the schema, contradicting the `valid` schemaTest and
|
|
/// producing a valid-schema-rejected false positive. Yet §4.2.2 makes the type's
|
|
/// `group` reference resolve to the redefined `all{e1(1,1)}`, against which the
|
|
/// single-`e1` instance is valid. The `valid` schema and `invalid` instance
|
|
/// expectations are mutually exclusive; libxml2 accepts both. Confirmed by an
|
|
/// adversarial analysis that found no third path.
|
|
///
|
|
/// - `particlesZ001.i`: a `complexContent` restriction `Derived` of `Base`, with an
|
|
/// instance valid against `Derived`'s own content model. cvc-complex-type (§3.4.4)
|
|
/// validates an instance against the element's own `{content type}` and never
|
|
/// re-runs Particle Valid (Restriction) / RecurseAsIfGroup (§3.9.6, a schema-
|
|
/// assembly constraint), so schema-valid + instance-invalid is unreachable. The
|
|
/// manifest itself labels the governing rule ambiguous; libxml2 accepts both.
|
|
/// Reaching `invalid` would require rejecting the schema (a valid-schema-rejected
|
|
/// false positive) and would still fail the suite's own `valid` schemaTest.
|
|
static let specDivergentInstances: Set<String> = [
|
|
"anyURI_a004_1339.i", "schA2.i", "schA5.i", "mgO013.i", "particlesZ001.i",
|
|
]
|
|
|
|
/// Schema tests excluded from the counts for the same reason: the expectation is
|
|
/// not authoritative. Each entry must name the settled expectation it is jointly
|
|
/// unsatisfiable with; this is never a place to hide a real deviation.
|
|
///
|
|
/// - `particlesZ008`: byte-for-byte the same construct as `elemZ026` (an abstract
|
|
/// head element, a member via `substitutionGroup`, a base type whose sequence
|
|
/// references the head, and a restriction that references the member instead),
|
|
/// yet Z008's settled expectation is `valid` while elemZ026's settled expectation
|
|
/// is `invalid`, both accepted on the same date. One expectation must be wrong,
|
|
/// and the spec decides which: NameAndTypeOK (section 3.9.6, Elt:Elt) clause 1
|
|
/// requires the declared {name}s and {target namespace}s to be the same, and no
|
|
/// clause grants substitution an allowance in particle restriction, so the member
|
|
/// swap is invalid and Z008's `valid` has no spec text behind it (its annotation
|
|
/// asserts "should be valid" without citing one). The schema is still compiled
|
|
/// so the group's instance tests run; only its verdict is excluded.
|
|
static let specDivergentSchemas: Set<String> = [
|
|
"particlesZ008",
|
|
]
|
|
}
|