在尝试使用我创建的模式文件:ListMatchingProductsResponse.xsd时,我遇到了一个类似于另一个职位的错误,但我不认为底层修复是相同的。
当我试图解析一个样本响应时
var ListMatchingProductsResponse = require('/mappings/ListMatchingProductsResponse').ListMatchingProductsResponse;
var Jsonix = require('jsonix').Jsonix;
var context = new Jsonix.Context([ListMatchingProductsResponse]);
var unmarshaller = context.createUnmarshaller();
unmarshaller.unmarshalFile('sample-response.xml',
function (unmarshalled) {
console.log('unmarshalled:', unmarshalled);
});
});最后,我:
Uncaught Error:
Element [{http://mws.amazonservices.com/schema/Products/2011-10-01}ListMatchingProductsResponse]
could not be unmarshalled as is not known in this context
and the property does not allow DOM content.我的怀疑:
到目前为止,我已经尝试过各种非智力的黑客,但不明白这里的问题是什么。希望拥有更好的鹰眼和理解能力的人能有所帮助。
对我来说最突出的是样本响应
ListMatchingProductsResponse与http://mws.amazonservices.com/schema/Products/2011-10-01命名空间联系起来http://localhost:8000/ListMatchingProductsResponse.xsd命名空间联系在一起,因为我是创建模式并将ListMatchingProductsResponse定义为complexType的人。下面是我的映射/ListMatchingProductsResponse.js文件的摘录,它是在运行后生成的:java -jar node_modules/jsonix/lib/jsonix-schema-compiler-full.jar -d mappings -p ListMatchingProductsResponse cache/xsd/localhost_8000/ListMatchingProductsResponse.xsd
{
localName: 'ListMatchingProductsResponse',
typeName: {
namespaceURI: 'http:\/\/localhost:8000\/ListMatchingProductsResponse.xsd',
localPart: 'ListMatchingProductsResponse'
},我试错的尝试:
我真的不想改变响应,因为我真的无法控制它,但我摆弄它,看看通过将名称空间修复为我的人工名称是否会有所不同,但这仍然导致相同的错误.只是现在被抱怨的名称空间是不同的:
Uncaught Error:
Element [{http://localhost:8000/ListMatchingProductsResponse.xsd}ListMatchingProductsResponse]
could not be unmarshalled as is not known in this context
and the property does not allow DOM content.发布于 2016-09-14 09:05:45
免责声明:,我是Jsonix的作者。
我至少看到了一些问题。
首先,我看不到模式中的元素声明。您正在尝试用ListMatchingProductsResponse命名空间对http://mws.amazonservices.com/schema/Products/2011-10-01进行封送,但是它在您的模式中声明在哪里?
接下来是您的模式作为目标命名空间。元素具有http://mws.amazonservices.com/schema/Products/2011-10-01命名空间。这很可疑。我并不是说这是错误的(因为没有全局元素声明),但我想您是在混合模式位置和命名空间URI。
因此,据我所知,您的模式不完整,XML也不匹配。我可能错了(我必须分析所有的导入才能确定),但我认为您需要添加全局元素并检查名称空间。
https://stackoverflow.com/questions/39480513
复制相似问题