私はjsonixを初めて使用し、主にxmlデータの非整列化に使用することに興味があります。非常に基本的なテスト例を作成しましたが、うまく動作しませんでした。
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;
名前空間を持ち、テスト xml の「hello」を含む単一の単純な要素をハードコードしました。一般的なアンマーシャリングの「任意の要素のマッピング」に興味がありました。コンテキストを作成するときに名前空間などを適切に構成したような気がしますが、次のエラーが発生し続けます: Element [sos:Capabilities] could not be unmarshalled as is not known in this context and the property does not allow DOM content. 考え?事前に感謝します。