Skip to content

Trying to understand why simple unmarshalling is failing  #145

@richard3d

Description

@richard3d

Hello,
I am new to jsonix and interested mostly in using it to unmarshall xml data. I wrote a very basic test example but have been unsuccessful in getting it to work.

var MyModule = {
    name: 'MyModule',
    typeInfos: [{
        type: 'classInfo',
        localName: 'AnyElementType',
        propertyInfos: [{
            type: 'anyElement',
            allowDom: true,
            allowTypedObject:true,
            name: 'any',
            collection: false
        }]
    }],
    elementInfos: [{
        elementName: 'sos:Capabilities',
        typeInfo: 'MyModule.AnyElementType'
    }]
  };

  var context = new Jsonix.Context([MyModule], {namespacePrefixes:  {'http://www.opengis.net/sos/2.0':'sos'}});
  var unmarshaller = context.createUnmarshaller();
  var data = unmarshaller.unmarshalString('<sos:Capabilities version=\"2.0.0\">hello</sos:Capabilities>');
  return data;

I hardcoded a single simple element that has a namespace and contains 'hello' for the test xml. I was interested in the 'any element mapping' for generic unmarshalling. I feel like I have the namespace configured appropriately etc when creating the context yet I keep getting the following error:
Element [sos:Capabilities] could not be unmarshalled as is not known in this context and the property does not allow DOM content. Thoughts? and thanks in advance.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions