Skip to content

Commit

Permalink
Adding unit test for #92.
Browse files Browse the repository at this point in the history
  • Loading branch information
leonelsanchesdasilva committed Sep 10, 2024
1 parent b665ca9 commit 3369ca3
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions tests/xslt/choose.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,90 @@ describe('xsl:choose', () => {
const html = await xsltClass.xsltProcess(xml, xslt);
assert.equal(html, '<products><product>No</product><product>Yes</product></products>');
});

it('https://github.com/DesignLiquido/xslt-processor/issues/92', async () => {
const xmlSource = `<sign gloss="simple">
<hamnosys_sign>
<sign2>
<minitialconfig2>
<handconfig2>
<handshape2>
<handshape1 handshapeclass="ham_flathand"/>
</handshape2>
</handconfig2>
</minitialconfig2>
</sign2>
</hamnosys_sign>
</sign>`;

const xsltSource = `<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- THESE OUTPUT SETTINGS MAY BE OVERRIDDEN BY THE H2S PROCESSOR: -->
<xsl:output method="xml" omit-xml-declaration="yes"
indent="yes" encoding="UTF-8"/>
<!--######## handShapeValue ########-->
<xsl:template name="handShapeValue">
<xsl:variable name="hs" select="@handshapeclass"/>
<xsl:value-of select="substring-after(concat(substring-before($hs,'hand'),$hs[not(contains(.,'hand'))]),'ham_')"/>
<xsl:if test="$hs='ham_flathand'">
<xsl:value-of select="'flat'"/>
</xsl:if>
<xsl:if test="$hs!='ham_flathand'">
<xsl:value-of select="substring-after($hs,'ham_')"/>
</xsl:if>
<xsl:choose>
<xsl:when test="$hs='ham_flathand'">
<xsl:value-of select="'flat'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring-after($hs,'ham_')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$hs='ham_flathand'">
<xsl:value-of select="'flat'"/>
</xsl:when>
</xsl:choose>
</xsl:template>
<!--######## sign ########-->
<xsl:template match="/">
<!--
<!ELEMENT sign (hamnosys_sign?)>
<!ATTLIST sign gloss CDATA #IMPLIED>
-->
<xsl:element name="hamgestural_sign">
<xsl:if test="@gloss">
<xsl:attribute name="gloss">
<xsl:value-of select="@gloss"/>
</xsl:attribute>
</xsl:if>
<xsl:element name="sign_manual">
<xsl:apply-templates select="sign/hamnosys_sign/sign2/minitialconfig2/handconfig2/handshape2/handshape1"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:transform>`;

const xsltClass = new Xslt();
const xmlParser = new XmlParser();
const xml = xmlParser.xmlParse(xmlSource);
const xslt = xmlParser.xmlParse(xsltSource);
const html = await xsltClass.xsltProcess(xml, xslt);
assert.equal(html, '<hamgestural_sign><sign_manual/></hamgestural_sign>');
});
});

0 comments on commit 3369ca3

Please sign in to comment.