我试图通过使用saxonjs将json输入转换成xml,这是我的代码的简化版本
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');
});我的xslt样式表如下所示:
<?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>如果我将match="/“替换为”match=“问题或"/issue”--结果是相同的,那么我做错了什么?
发布于 2021-12-08 14:30:01
/匹配文档节点或文档片段节点,您的项不是节点,而是XPath 3.1映射,使用match="."匹配任何项,使用match=".[. instance of map(*)]"匹配任何映射项。
https://stackoverflow.com/questions/70276546
复制相似问题