【发布时间】:2016-09-13 23:41:43
【问题描述】:
在尝试使用我创建的架构文件:ListMatchingProductsResponse.xsd 时,我遇到了类似于 another post 的错误,但我认为底层修复不一样。
当我尝试解析 sample response:
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.
我的怀疑:
到目前为止,我已经尝试了各种非智能黑客,但只是不明白这里的问题是什么。希望有更好的鹰眼观点和理解力的人可以提供帮助。
对我来说最明显的是sample response
- 将
ListMatchingProductsResponse与http://mws.amazonservices.com/schema/Products/2011-10-01命名空间联系起来 - 而我的架构将其与人工的
http://localhost:8000/ListMatchingProductsResponse.xsd命名空间相关联,因为我是创建架构并将ListMatchingProductsResponse定义为complexType的人。
这是我运行后生成的mappings/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.
【问题讨论】:
标签: amazon-mws jsonix