Skip to content

xsl:attribute with an attribute without a prefix should always be created in the null namespace #5

Description

@DrRataplan

If the namespace attribute is not present, then the lexical QName is expanded into an expanded QName using the namespace declarations in effect for the xsl:attribute element, not including any default namespace declaration.

Minimal repro:

import { compile } from "../src/compile";
import * as slimdom from "slimdom";
import { evaluateXPathToNodes } from "fontoxpath";

test("xsl:attribute unprefixed name gets no namespace even with default namespace in scope", async () => {
  const xslt = slimdom.parseXmlDocument(`
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns="http://www.w3.org/1999/xhtml">
      <xsl:template match="/">
        <xsl:element name="p">
          <xsl:attribute name="class">foo</xsl:attribute>
        </xsl:element>
      </xsl:template>
    </xsl:stylesheet>`);
  const transform = await compile(xslt);
  const result = transform(slimdom.parseXmlDocument("<root/>")).get("#default").document;
  const p = evaluateXPathToNodes("/p", result)[0] as slimdom.Element;
  expect(p.getAttribute("class")).toEqual("foo");
  expect(p.getAttributeNS("http://www.w3.org/1999/xhtml", "class")).toBeNull();
});

Fixed in #4

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions