@testable import PureXML import Testing @Suite("XSD top-level attribute applicability (topLevelAttribute)") struct SchemaTopLevelAttributeTests { private let xsd = "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"" private func compiles(_ body: String) -> Bool { (try? PureXML.Schema.Document("\(body)")) != nil } @Test("A top-level attribute with use is rejected") func test_topLevelUseRejected() { #expect(!compiles("")) #expect(!compiles("")) #expect(!compiles("")) } @Test("A top-level attribute with form is rejected") func test_topLevelFormRejected() { #expect(!compiles("")) } @Test("A plain top-level attribute declaration compiles") func test_plainTopLevelAccepted() { #expect(compiles("")) #expect(compiles("")) } /// `use`, `form`, and a `ref` are legitimate on a LOCAL attribute use inside a /// complex type; the rule applies only to top-level declarations. @Test("A local attribute use with use/form compiles") func test_localUseAccepted() { #expect(compiles( "" + "" + "", )) // A local ref with use is fine. #expect(compiles( "" + "" + "" + "", )) } }