1+ /* eslint-disable no-undef */
2+ import assert from 'assert' ;
3+
4+ import { Xslt } from '../src/xslt' ;
5+ import { XmlParser } from '../src/dom' ;
6+
7+ describe ( 'Interactive Tests Examples' , ( ) => {
8+ // TODO: Per https://github.com/DesignLiquido/xslt-processor/issues/116, while debugging
9+ // this test, we've found that `<xsl:apply-templates>` with a `select` attribute +
10+ // `<xsl:template>` does not work well for relative XPath (it works for absolute XPath).
11+ // The problem happens because the implementation calls the traditional `<xsl:template>`,
12+ // which it tries to re-select nodes that are already selected in the expression context by
13+ // `<xsl:apply-templates>`. Instead, it should "select the appropriate template", as mentioned
14+ // at https://www.w3.org/TR/xslt-10/#section-Applying-Template-Rules and
15+ // https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/ms256184(v=vs.100),
16+ // and process each child by the selected template.
17+ it . skip ( 'Former xslt.html' , async ( ) => {
18+ const xmlString = (
19+ `<page>
20+ <message>
21+ Hello World.
22+ </message>
23+ </page>`
24+ ) ;
25+
26+ const xsltString =
27+ `<?xml version="1.0"?>
28+ <xsl:stylesheet>
29+ <xsl:template match="/">
30+ <xsl:apply-templates select="page/message"/>
31+ </xsl:template>
32+
33+ <xsl:template match="page/message">
34+ <div style="color:green">
35+ <xsl:value-of select="."/>
36+ </div>
37+ </xsl:template>
38+ </xsl:stylesheet>` ;
39+
40+ const xsltClass = new Xslt ( ) ;
41+ const xmlParser = new XmlParser ( ) ;
42+ const xml = xmlParser . xmlParse ( xmlString ) ;
43+ const xslt = xmlParser . xmlParse ( xsltString ) ;
44+
45+ const outXmlString = await xsltClass . xsltProcess ( xml , xslt ) ;
46+
47+ assert . ok ( outXmlString ) ;
48+ } ) ;
49+ } ) ;
0 commit comments