Skip to content

xsl:template transformation packs text nodes to the beginning #109

@jrutila

Description

@jrutila

This test case will show the problem. The output is now XYtest1 even though it should be Xtest1Y. I think it is because the text nodes get siblingPosition of -1 and the xsl:value-of gets bigger than 0. Then, when it is rendering, it sorts the siblings by siblingPosition.

    it('XSLT template with text on both sides', async () => {
        const xmlString = `<root>
          <test name="test1">This text lost</test>
        </root>`;

        const xsltString = `<?xml version="1.0"?>
          <xsl:stylesheet version="1.0">
            <xsl:template match="/">
              <span>X<xsl:value-of select="test/@name" />Y</span>
            </xsl:template>
          </xsl:stylesheet>`;

        const expectedOutString = `<span>Xtest1Y</span>`;

        const xsltClass = new Xslt();
        const xmlParser = new XmlParser();
        const xml = xmlParser.xmlParse(xmlString);
        const xslt = xmlParser.xmlParse(xsltString);

        const outXmlString = await xsltClass.xsltProcess(xml, xslt);

        assert.equal(outXmlString, expectedOutString);
    });

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions