fix(schema): a restriction's attribute wildcard must subset the base's (#145)
cos-ct-restricts.4: a base type with no attribute wildcard admits none (so a restriction may not introduce one), and a wider namespace constraint such as ##any over ##other, or a weakened processContents, is not a subset. Reuses the wildcard subset check (ParticleRestriction.narrows, now internal). XSTS invalid-schemas-accepted 131 to 128, no other bucket moved.
This commit is contained in:
parent
c029505c3e
commit
ceca006c45
@ -22,6 +22,8 @@ Second pre-release. Continues the W3C XSTS schema-validity campaign: **invalid-s
|
||||
|
||||
### Fixed
|
||||
|
||||
- XSTS invalid-schemas-accepted (#145): a complexContent restriction's own attribute wildcard must be a subset of the base's (`cos-ct-restricts.4`). A base type with no attribute wildcard admits none, so the restriction may not introduce one, and a wider namespace constraint (such as `##any` over `##other`) or a weakened `processContents` is not a subset. Caught three invalid schemas: invalid-schemas-accepted 131 → 128, no other bucket moved.
|
||||
|
||||
- XSTS invalid-schemas-accepted (#145): a complexContent restriction may not add an attribute the base type never permitted. An attribute the restriction declares that has no matching base attribute use must be admitted by the base's `anyAttribute` wildcard (`cos-ct-restricts.3`); for example a no-namespace attribute is not admitted by a `##other` wildcard. A `prohibited` declaration (which removes an attribute) stays valid. Caught one invalid schema: invalid-schemas-accepted 132 → 131, no other bucket moved.
|
||||
|
||||
- XSTS invalid-schemas-accepted (#145): a namespace value may not be the empty string. `<schema targetNamespace="">` and `<import namespace="">` are rejected, since a namespace name must be a non-empty `anyURI` (omitting the attribute, for no target namespace or a no-namespace import, stays valid). Caught two invalid schemas: invalid-schemas-accepted 134 → 132, no other bucket moved.
|
||||
|
||||
@ -267,7 +267,10 @@ extension PureXML.Schema {
|
||||
}
|
||||
|
||||
/// Whether the restricted wildcard admits no namespace the base refuses.
|
||||
private static func narrows(_ restricted: Wildcard, _ base: Wildcard) -> Bool {
|
||||
/// Whether `restricted` is a valid subset of `base` (Wildcard Subset): its
|
||||
/// processContents is at least as strong and its namespace constraint is
|
||||
/// narrower or equal. Shared with attribute-wildcard restriction.
|
||||
static func narrows(_ restricted: Wildcard, _ base: Wildcard) -> Bool {
|
||||
// Wildcard Subset (XSD 1.0 §3.10.6): the restriction's processContents
|
||||
// must be identical to or STRONGER than the base's (strict > lax > skip);
|
||||
// a restriction may not weaken validation. Namespace narrowing is below.
|
||||
|
||||
@ -34,6 +34,19 @@ extension PureXML.Schema.XSDParser {
|
||||
errors.append(message)
|
||||
}
|
||||
}
|
||||
// cos-ct-restricts.4: a restriction's own attribute wildcard must be a
|
||||
// subset of the base's. A base with no wildcard admits none, so the
|
||||
// restriction may not introduce one (ctO005); a wider namespace
|
||||
// constraint, such as `##any` over `##other`, is not a subset (ctO007).
|
||||
if let derivedWildcard = attributeWildcard(under: restriction, context) {
|
||||
if let baseWildcard = complex.attributeWildcard {
|
||||
if !PureXML.Schema.ParticleRestriction.narrows(derivedWildcard, baseWildcard) {
|
||||
errors.append("the restriction's attribute wildcard is not a subset of the base type's attribute wildcard")
|
||||
}
|
||||
} else {
|
||||
errors.append("a restriction may not introduce an attribute wildcard that the base type does not have")
|
||||
}
|
||||
}
|
||||
}
|
||||
return errors
|
||||
}
|
||||
|
||||
@ -115,8 +115,12 @@ struct XSTSSuiteTests {
|
||||
/// to be admitted by the base's attribute wildcard (cos-ct-restricts.3) then
|
||||
/// caught one more invalid schema: invalid-schemas accepted 132 → 131, no other
|
||||
/// bucket moved.
|
||||
/// Requiring a restriction's own attribute wildcard to be a subset of the base's
|
||||
/// (cos-ct-restricts.4: a base without one admits none; `##any` over `##other` is
|
||||
/// not a subset) then caught three more invalid schemas: invalid-schemas accepted
|
||||
/// 131 → 128, no other bucket moved.
|
||||
private let knownSchemaValidRejected = 1
|
||||
private let knownSchemaInvalidAccepted = 131
|
||||
private let knownSchemaInvalidAccepted = 128
|
||||
private let knownInstanceValidRejected = 3
|
||||
private let knownInstanceInvalidAccepted = 132
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user