Skip to content

XSLT transformation not working as expected #126

@fergiemcdowall

Description

@fergiemcdowall

Hi and thanks for this library 👍

The following does not work as expected- does the fault lie with me or with xslt-processor?

import { Xslt, XmlParser } from 'xslt-processor'

const xmlString = `<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>Fergie</title>
</feed>`

const xsltString = `<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:atom="http://www.w3.org/2005/Atom"
  exclude-result-prefixes="atom"
  >
  
  <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>

  <xsl:template match="/atom:feed">
    <h1><xsl:value-of select="atom:title"/>'s Web Feed Preview</h1>
  </xsl:template>

</xsl:stylesheet>
`

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)
// ?
// outXmlString is "<h1>'s Web Feed Preview</h1>" and not "<h1>Fergie's Web Feed Preview</h1>" as expected)
// ?

console.assert(
  outXmlString == '<h1>Fergie's Web Feed Preview</h1>',
  '%o',
  `String is not as expected: ${outXmlString}`
)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions