import Testing @testable import PureXML @Suite("XSD top-level element applicability (topLevelElement)") struct SchemaTopLevelElementTests { 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 element with ref/form/minOccurs/maxOccurs is rejected") func test_topLevelForbiddenRejected() { #expect(!compiles("")) #expect(!compiles("")) #expect(!compiles("")) #expect(!compiles("")) } @Test("A plain top-level element declaration compiles") func test_plainTopLevelAccepted() { #expect(compiles("")) #expect(compiles("")) } /// `ref`, `minOccurs`, and `maxOccurs` are legitimate on a LOCAL element /// particle inside a complex type; the rule applies only to top-level /// declarations. @Test("A local element ref with occurrence compiles") func test_localParticleAccepted() { #expect(compiles( "" + "" + "" + "", )) } }