import Testing @testable import PureXML @Suite("XSD type attribute excludes an inline type") struct SchemaTypeExclusivityTests { private let xsd = "xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"" private func compiles(_ body: String) -> Bool { (try? PureXML.Schema.Document("\(body)")) != nil } @Test("type attribute and an inline type definition are mutually exclusive") func test_typeAndInlineTypeRejected() { // Element with both type= and an inline simpleType (src-element.3). #expect(!compiles("" + "")) // Element with both type= and an inline complexType. #expect(!compiles("")) // Attribute with both type= and an inline simpleType (src-attribute.3.1). #expect(!compiles("" + "")) } @Test("type alone, or an inline type alone, compiles") func test_eitherAloneAccepted() { #expect(compiles("")) #expect(compiles("")) #expect(compiles("")) // type= alongside an identity constraint (not a type) is legal. #expect(compiles("")) } @Test("A foreign-namespace child named simpleType/complexType is not the component's inline type") func test_foreignNamespaceChildNotInlineType() { // A foreign child whose local name happens to be complexType is not an XSD // inline type, so type= alongside it is not the type/inline-type clash. let schema = "" + "" #expect((try? PureXML.Schema.Document(schema)) != nil) } }