我有两个不同的XML结构,我想映射到一个域对象。我正在使用MOXy的外部绑定支持,这样我就可以选择动态使用哪个绑定。
这是我的问题。我有一个XML结构,如下所示:
<entity>
<compoundID_one>foo</compoundID_one>
<compoundID_two>bar</compoundID_two>
</entity>
我想要一个单人间
List<String>
域类中包含“foo”和“bar”的字段
我试过了:
...
<java-attributes>
<xml-elements>
<xml-element java-attribute="idList" name="compoundID_one" />
<xml-element java-attribute="idList" name="compoundID_two" />
</xml-elements>
</java-attributes>
...
但我只是明白
null
域对象中的字段。如果我省略了
xml-elements
wrapper我只得到列表中的一个compoundID。
我发现了这个
question
这似乎表明这应该奏效。我做错了什么吗?或者有更好的方法吗?