import Testing @testable import PureXML @Suite("XSLT xsl:namespace-alias") struct XSLTNamespaceAliasTests { private let xsl = "xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"" private func transform(_ stylesheet: String, _ source: String) throws -> String { try PureXML.XSLT.transform(stylesheet: stylesheet, source: source) } @Test("A literal element in the aliased namespace keeps its prefix, with the result namespace") func test_rewrite() throws { let style = """ """ // 7.1.1: the literal prefix `a` is kept and only its namespace URI is // remapped to the result namespace; the result-prefix `b` selects the // namespace, it is not adopted as the output prefix (Apache Xalan // namespace19, namespace23, namespace24, namespace35, namespace113). #expect(try transform(style, "") == "") } @Test("A non-aliased literal element still copies in-scope declarations") func test_notAliased() throws { let style = """ """ // Both in-scope namespaces are copied; the aliased `a` keeps its prefix // with its URI remapped to the result namespace, alongside `b`. #expect(try transform(style, "") == "") } @Test("namespace-alias can produce literal xsl: elements (stylesheet generation)") func test_generateXSL() throws { let style = """ """ let out = try transform(style, "") // The aliased axsl: element keeps its prefix but is bound to the XSLT // namespace, so it is a literal xsl:value-of (axsl maps to Transform), // not run as an instruction. #expect(out == "") } }