import Testing @testable import PureXML /// XSLT 1.0 names every QName-keyed declaration by expanded name, so two /// prefixes bound to the same namespace name the same thing. Declared with one /// prefix and referenced with another (both bound to `urn:q`), each must still /// resolve (Apache Xalan namedtemplate16, attribset48, idkey53). @Suite("XSLT expanded-name QName declarations") struct XSLTExpandedQNameTests { private let namespaces = "xmlns:a=\"urn:q\" xmlns:b=\"urn:q\"" private let xsl = "xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"" private func run(_ body: String, _ extra: String = "") throws -> String { try PureXML.XSLT.transform( stylesheet: """ \(extra) \(body) """, source: "V", ) } @Test("call-template matches a template named with a different same-namespace prefix") func test_namedTemplate() throws { let out = try run("", "T") #expect(out == "T") } @Test("use-attribute-sets matches an attribute-set named with a different prefix") func test_attributeSet() throws { let out = try run( "", "1", ) #expect(out == "") } @Test("key() matches an xsl:key named with a different prefix") func test_key() throws { let out = try run( "", "", ) #expect(out == "V") } @Test("format-number matches an xsl:decimal-format named with a different prefix") func test_decimalFormat() throws { let out = try run( "", "", ) #expect(out == "5") } }