import Testing @testable import PureXML /// `use="prohibited"` excludes an attribute from a complex type's effective /// {attribute uses} (XSD 1.0 ยง3.4.2): the attribute is then undeclared, so its /// presence is rejected when no wildcard admits it, but is still admitted (and /// validated per `processContents`) when an attribute wildcard covers it. The /// prohibited declaration is kept for schema-validity checks, not dropped. @Suite("prohibited attribute use") struct SchemaProhibitedAttributeTests { @Test("a prohibited attribute with no wildcard is rejected when present") func test_prohibitedNoWildcardRejected() throws { let schema = try PureXML.Schema.Document(""" """) #expect(try !schema.validate(#""#).isEmpty) // Omitting the prohibited attribute, with the allowed one, is valid. #expect(try schema.validate(#""#).isEmpty) } /// The W3C attZ002 shape: a prohibited attribute is still admitted by a lax /// `anyAttribute` wildcard, so the instance is valid (the prohibition removes /// the use, the wildcard independently admits the name). @Test("a prohibited attribute admitted by a wildcard is accepted") func test_prohibitedAdmittedByWildcardAccepted() throws { let schema = try PureXML.Schema.Document(""" """) #expect(try schema.validate(#""#).isEmpty) } }