Skip to content

Incorrect output for Mozilla example #110

@erickoledadevrel

Description

@erickoledadevrel

When testing this library I used a sample XML + XSLT from the Mozilla website. The library doesn't seem to work correctly with this example, although I haven't been able to determine why exactly.

Repro

  1. Install the library.
  2. Run the following code (Node.js).
const xslt = require('xslt-processor');

const xmlString = `
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="example.xsl"?>
<Article>
  <Title>My Article</Title>
  <Authors>
    <Author>Mr. Foo</Author>
    <Author>Mr. Bar</Author>
  </Authors>
  <Body>This is my article text.</Body>
</Article>
`;

const xsltString = `
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="text"/>

  <xsl:template match="/">
    Article - <xsl:value-of select="/Article/Title"/>
    Authors: <xsl:apply-templates select="/Article/Authors/Author"/>
  </xsl:template>

  <xsl:template match="Author">
    - <xsl:value-of select="." />
  </xsl:template>

</xsl:stylesheet>
`;

const processor = new xslt.Xslt();
const parser = new xslt.XmlParser();
const result = processor.xsltProcess(
  parser.xmlParse(xmlString),
  parser.xmlParse(xsltString)
).then(result => console.log(result));

Expected


    Article - My Article
    Authors: 
    - Mr. Foo
    - Mr. Bar

Actual


    - My ArticleMr. FooMr. Bar

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