Skip to content

Commit 3369ca3

Browse files
Adding unit test for #92.
1 parent b665ca9 commit 3369ca3

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

tests/xslt/choose.test.tsx

+86
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,90 @@ describe('xsl:choose', () => {
4444
const html = await xsltClass.xsltProcess(xml, xslt);
4545
assert.equal(html, '<products><product>No</product><product>Yes</product></products>');
4646
});
47+
48+
it('https://github.com/DesignLiquido/xslt-processor/issues/92', async () => {
49+
const xmlSource = `<sign gloss="simple">
50+
<hamnosys_sign>
51+
<sign2>
52+
<minitialconfig2>
53+
<handconfig2>
54+
<handshape2>
55+
<handshape1 handshapeclass="ham_flathand"/>
56+
</handshape2>
57+
</handconfig2>
58+
</minitialconfig2>
59+
</sign2>
60+
</hamnosys_sign>
61+
</sign>`;
62+
63+
const xsltSource = `<xsl:transform version="1.0"
64+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
65+
66+
<!-- THESE OUTPUT SETTINGS MAY BE OVERRIDDEN BY THE H2S PROCESSOR: -->
67+
68+
<xsl:output method="xml" omit-xml-declaration="yes"
69+
indent="yes" encoding="UTF-8"/>
70+
71+
<!--######## handShapeValue ########-->
72+
73+
<xsl:template name="handShapeValue">
74+
75+
<xsl:variable name="hs" select="@handshapeclass"/>
76+
<xsl:value-of select="substring-after(concat(substring-before($hs,'hand'),$hs[not(contains(.,'hand'))]),'ham_')"/>
77+
78+
<xsl:if test="$hs='ham_flathand'">
79+
<xsl:value-of select="'flat'"/>
80+
</xsl:if>
81+
<xsl:if test="$hs!='ham_flathand'">
82+
<xsl:value-of select="substring-after($hs,'ham_')"/>
83+
</xsl:if>
84+
85+
<xsl:choose>
86+
<xsl:when test="$hs='ham_flathand'">
87+
<xsl:value-of select="'flat'"/>
88+
</xsl:when>
89+
<xsl:otherwise>
90+
<xsl:value-of select="substring-after($hs,'ham_')"/>
91+
</xsl:otherwise>
92+
</xsl:choose>
93+
94+
<xsl:choose>
95+
<xsl:when test="$hs='ham_flathand'">
96+
<xsl:value-of select="'flat'"/>
97+
</xsl:when>
98+
</xsl:choose>
99+
100+
</xsl:template>
101+
102+
<!--######## sign ########-->
103+
104+
<xsl:template match="/">
105+
<!--
106+
<!ELEMENT sign (hamnosys_sign?)>
107+
<!ATTLIST sign gloss CDATA #IMPLIED>
108+
-->
109+
110+
<xsl:element name="hamgestural_sign">
111+
112+
<xsl:if test="@gloss">
113+
<xsl:attribute name="gloss">
114+
<xsl:value-of select="@gloss"/>
115+
</xsl:attribute>
116+
</xsl:if>
117+
118+
<xsl:element name="sign_manual">
119+
<xsl:apply-templates select="sign/hamnosys_sign/sign2/minitialconfig2/handconfig2/handshape2/handshape1"/>
120+
</xsl:element>
121+
122+
</xsl:element>
123+
</xsl:template>
124+
</xsl:transform>`;
125+
126+
const xsltClass = new Xslt();
127+
const xmlParser = new XmlParser();
128+
const xml = xmlParser.xmlParse(xmlSource);
129+
const xslt = xmlParser.xmlParse(xsltSource);
130+
const html = await xsltClass.xsltProcess(xml, xslt);
131+
assert.equal(html, '<hamgestural_sign><sign_manual/></hamgestural_sign>');
132+
});
47133
});

0 commit comments

Comments
 (0)