1
0
Fork 0
firefox/testing/web-platform/tests/dom/xslt/document-element.window.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

26 lines
815 B
JavaScript

const xmlString = `
<items>
<item>Item 1</item>
<item>Item 2</item>
</items>
`;
const xsltString = `
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="*">
<xsl:value-of select="name(.)"/>
</xsl:template>
</xsl:stylesheet>
`;
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlString, "application/xml");
const xsltDoc = parser.parseFromString(xsltString, "application/xml");
const xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsltDoc);
test(() => {
const resultFragment = xsltProcessor.transformToFragment(xmlDoc.documentElement, document);
assert_equals(resultFragment.childNodes.length, 1);
assert_equals(resultFragment.firstChild.nodeValue, "items");
}, `'*' should match the documentElement`);