首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >saxonjs忽略json输入的匹配规则。

saxonjs忽略json输入的匹配规则。
EN

Stack Overflow用户
提问于 2021-12-08 14:20:30
回答 1查看 81关注 0票数 0

我试图通过使用saxonjs将json输入转换成xml,这是我的代码的简化版本

代码语言:javascript
复制
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样式表如下所示:

代码语言:javascript
复制
<?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”--结果是相同的,那么我做错了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-12-08 14:30:01

/匹配文档节点或文档片段节点,您的项不是节点,而是XPath 3.1映射,使用match="."匹配任何项,使用match=".[. instance of map(*)]"匹配任何映射项。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70276546

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档