In my attempt to use a schema file that I created: ListMatchingProductsResponse.xsd, I run into an error similar to another post but I don't think that the underlying fix is that same.
When I try to parse a 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);
});
});
I end up with:
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.
My Suspicions:
I've tried various unintelligent hacks thus far but just don't understand what the problem here is. Hoping that someone with a better eagle-eye view and understanding can help.
What sticks out most clearly for me is that the sample response
- ties
ListMatchingProductsResponse
with thehttp://mws.amazonservices.com/schema/Products/2011-10-01
namespace - whereas my schema ties it to the artificial
http://localhost:8000/ListMatchingProductsResponse.xsd
namespace because I'm the one creating the schema and definingListMatchingProductsResponse
as acomplexType
.
Here's an excerpt from my mappings/ListMatchingProductsResponse.js file which is generated after running: 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'
},
My attempts at trial & error:
I really did not want to change the response because I really have no control over it but I fiddled with it to see if things could be different by fixing the namespace to be my artificial one but that still resulted in the same error ... just that now the namespace being complained about is different:
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.