diff --git a/CHANGELOG.md b/CHANGELOG.md index cf5e47d..6b03520 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): a referencing `attributeGroup` (one carrying a `ref`) is held to its `(annotation?)` content model. It names a definition elsewhere, so it may not itself declare attributes, nested attributeGroup references, or an `anyAttribute`; only a defining `attributeGroup` (with `name`) carries those (`attgD`). Caught three invalid schemas: invalid-schemas-accepted 210 → 207, no other bucket moved. + - 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. diff --git a/Sources/Schema/SchemaStructureHelpers.swift b/Sources/Schema/SchemaStructureHelpers.swift index 1a394bc..d1e32c1 100644 --- a/Sources/Schema/SchemaStructureHelpers.swift +++ b/Sources/Schema/SchemaStructureHelpers.swift @@ -169,7 +169,16 @@ extension PureXML.Schema.XSDParser { return errors } - static func attributeGroupChildrenErrors(_: XSDTree, names: [String]) -> [String] { + static func attributeGroupChildrenErrors(_ node: XSDTree, names: [String]) -> [String] { + // A referencing attributeGroup (one with `ref`) names a definition elsewhere; + // its own content model is (annotation?), so it may not also declare + // attributes, nested attributeGroup references, or an anyAttribute. Only a + // defining attributeGroup (with `name`) carries those. + if PureXML.Schema.XSDNode.attribute(node, "ref") != nil { + return names.contains { $0 != "annotation" } + ? ["an attributeGroup reference may contain only an optional annotation"] + : [] + } var errors: [String] = [] let anyAttributes = names.count { $0 == "anyAttribute" } if anyAttributes > 1 { diff --git a/Tests/XSTSSuiteTests.swift b/Tests/XSTSSuiteTests.swift index acfde00..a52dc2d 100644 --- a/Tests/XSTSSuiteTests.swift +++ b/Tests/XSTSSuiteTests.swift @@ -113,8 +113,12 @@ struct XSTSSuiteTests { /// 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. + /// Holding a referencing `attributeGroup` (one with `ref`) to its `(annotation?)` + /// content model, so it may not also declare attributes, nested attributeGroup + /// references, or an anyAttribute, then caught three more invalid schemas: + /// invalid-schemas accepted 210 → 207, no other bucket moved. private let knownSchemaValidRejected = 1 - private let knownSchemaInvalidAccepted = 210 + private let knownSchemaInvalidAccepted = 207 private let knownInstanceValidRejected = 3 private let knownInstanceInvalidAccepted = 132