私が作成したスキーマ ファイル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
.
実行後に生成される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.