From 709d23cc34a38253d5b27aebe9009d0249cfa688 Mon Sep 17 00:00:00 2001 From: Mihaela Mihaljevic Date: Wed, 17 Jun 2026 14:21:57 +0200 Subject: [PATCH] fix(schema): include notation names in component-name uniqueness (#145) A notation declaration occupies its own symbol space, so two notations sharing a name and target namespace are a duplicate just as two global types or elements would be. Notations were omitted from the uniqueness check. XSTS invalid-schemas-accepted 211 to 210, no other bucket moved. --- CHANGELOG.md | 2 ++ Sources/Schema/SchemaNameUniqueness.swift | 6 ++++-- Tests/XSTSSuiteTests.swift | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29a40eb..cf5e47d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ Second pre-release. Continues the W3C XSTS schema-validity campaign: **invalid-s ### Fixed +- XSTS invalid-schemas-accepted (#145): notation names are now part of the component-name uniqueness check. A notation has its own symbol space, so two notations sharing a name and target namespace are a duplicate just as two global types or elements would be (`notatB005`). Caught one invalid schema: invalid-schemas-accepted 211 → 210, no other bucket moved. + - XSTS invalid-schemas-accepted (#145): an `xsd:notation` declaration is held to its `(annotation?)` content model. A notation may carry only an optional `annotation` child, so any other element child, or any non-whitespace character content, is now rejected (`notatG`). Caught three invalid schemas: invalid-schemas-accepted 214 → 211, no other bucket moved. - XSTS invalid-schemas-accepted (#145): a `list` simple type must draw its item type from exactly one of an `itemType` attribute or an inline `simpleType` child (neither, or both, is invalid), and a `union` must declare at least one member type through a `memberTypes` attribute or an inline `simpleType` child (an empty `union` declares none), per `src-simple-type.2`/`.3`. Caught one invalid schema: invalid-schemas-accepted 215 → 214, no other bucket moved. diff --git a/Sources/Schema/SchemaNameUniqueness.swift b/Sources/Schema/SchemaNameUniqueness.swift index 7e16946..8d2a78d 100644 --- a/Sources/Schema/SchemaNameUniqueness.swift +++ b/Sources/Schema/SchemaNameUniqueness.swift @@ -1,8 +1,9 @@ extension PureXML.Schema.XSDParser { /// Schema-validity findings for component-name uniqueness. Within a schema, /// global type names (simpleType and complexType share one symbol space), - /// global element names, global attribute names, named model-group names, and - /// named attribute-group names must each be unique; identity-constraint names + /// global element names, global attribute names, named model-group names, + /// named attribute-group names, and notation names must each be unique; + /// identity-constraint names /// (unique/key/keyref) must be unique across the whole schema. A duplicate was /// accepted, with a later definition silently overwriting the earlier one. /// @@ -112,6 +113,7 @@ extension PureXML.Schema.XSDParser { case "attribute": "attribute" case "group": "group" case "attributeGroup": "attributeGroup" + case "notation": "notation" default: nil } } diff --git a/Tests/XSTSSuiteTests.swift b/Tests/XSTSSuiteTests.swift index 962fcfb..acfde00 100644 --- a/Tests/XSTSSuiteTests.swift +++ b/Tests/XSTSSuiteTests.swift @@ -109,8 +109,12 @@ struct XSTSSuiteTests { /// (no element child other than an annotation, no non-whitespace character /// content) then caught three more invalid schemas: invalid-schemas accepted /// 214 → 211, no other bucket moved. + /// Adding notations to the component-name uniqueness check (they have their own + /// symbol space; two notations of the same name and namespace clash) then caught + /// one more invalid schema: invalid-schemas accepted 211 → 210, no other bucket + /// moved. private let knownSchemaValidRejected = 1 - private let knownSchemaInvalidAccepted = 211 + private let knownSchemaInvalidAccepted = 210 private let knownInstanceValidRejected = 3 private let knownInstanceInvalidAccepted = 132