tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

document-element.window.js (815B)


      1 const xmlString = `
      2 <items>
      3  <item>Item 1</item>
      4  <item>Item 2</item>
      5 </items>
      6 `;
      7 const xsltString = `
      8 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      9  <xsl:template match="*">
     10    <xsl:value-of select="name(.)"/>
     11  </xsl:template>
     12 </xsl:stylesheet>
     13 `;
     14 const parser = new DOMParser();
     15 
     16 const xmlDoc = parser.parseFromString(xmlString, "application/xml");
     17 const xsltDoc = parser.parseFromString(xsltString, "application/xml");
     18 const xsltProcessor = new XSLTProcessor();
     19 
     20 xsltProcessor.importStylesheet(xsltDoc);
     21 
     22 test(() => {
     23  const resultFragment = xsltProcessor.transformToFragment(xmlDoc.documentElement, document);
     24  assert_equals(resultFragment.childNodes.length, 1);
     25  assert_equals(resultFragment.firstChild.nodeValue, "items");
     26 }, `'*' should match the documentElement`);