xml – saxonjs ignores match rules for json input
I’m trying to convert a json input into xml by using saxonjs, this is a simplified version of my code
const fs = require('fs');
const saxonJS = require('saxon-js');
const input = JSON.stringify({issue: {id: 'A001', number: 200 }});
saxonJS.transform({
stylesheetLocation: './issues.sef.json',
sourceType: 'json',
sourceText: JSON.stringify(input),
destination: 'serialized'}, 'async').then(data => {
console.log(data.principalResult);
res.status(200).send('Ok');
});
})
.catch(err => {
console.log(err);
res.status(500).send('error');
});
My xslt stylesheet is like this:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<xsl:template match="/">
<Issue xmlns="urn:mycompany:2021">
</Issue>
</xsl:template>
</xsl:stylesheet>
The result is always empty or more precisely <?xml version="1.0" encoding="utf-8"?>
If I replace match=”/” with match=”issue” or “/issue” the result is the same, what am I doing wrong?
Read more here: Source link