0

@xmlseealso jaxb 在simplexml中的等价物是什么。Iam 解析的响应如下所示:

<things xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:type="thing">
    <val>185</val>
</things>
<things xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:type="thing">
    <val>162</val>
</things>

我正在寻找这样的响应映射

Response.java

@ElementList
List<Object> things;

Thing.java

@Element
int val;

如何像在 jaxb 中使用 xmlseealso 那样动态地将“事物”映射到“事物”列表。Simplexml 有办法吗?

4

1 回答 1

0

如果您的意思是匹配不同类的元素列表但具有共享超类,那么解决方案是 @ElementListUnion 注释。您的

@XmlSeeAlso({X.class, Y.class, Z.class})

应表示为:

@ElementListUnion({
   @ElementList(entry="x", inline=true, type=X.class),
   @ElementList(entry="y", inline=true, type=Y.class),
   @ElementList(entry="z", inline=true, type=Z.class)               
})
private List<Superclass> xyz;

http://simple.sourceforge.net/download/stream/doc/javadoc/org/simpleframework/xml/ElementListUnion.html

于 2013-04-15T12:11:30.323 回答