0

我正在尝试将 xml 文件转换为具有 xsd 架构的 JSON 对象。我正在使用 nodeJS 来做到这一点。我已经创建了映射对象,但我不断收到此错误:“(..)无法解组,因为在此上下文中未知,并且该属性不允许 DOM 内容。”

这是我的代码:

var fs = require('fs');
var Jsonix = require('jsonix').Jsonix;
var PO = require(__dirname + '/../mappings/PO').PO;

var context = new Jsonix.Context([PO]);
var unmarshaller = context.createUnmarshaller();
unmarshaller.unmarshalFile(__dirname + '123456.xml', function (unmarshalled) {
    console.log(unmarshalled.value.author);
});

这是 xsd 模式的一部分(只是标头定义):

<xs:schema xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:editix="http://www.portalfiscal.inf.br/nfe" xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.portalfiscal.inf.br/nfe">

关于我做错了什么的任何想法?

4

0 回答 0