我尝试解决从xml到Java对象的映射列表的高级问题。
我可以给问题命名:EVE XML API
该链接显示了一个我无法逆向工程的问题:相同的元素标记具有不同的内容,但具有不同值的相同属性。
将对象序列化为XML非常有效,但它无法从生成的XML转换回对象。
我做了各种类的映射:
```
XStream xStream = new XStream( );
// Aliases
xStream.alias("eveapi", CallList.class);
xStream.aliasAttribute(CallList.class, "version", "version");
xStream.alias("row", RowCallGroups.class);
xStream.aliasField("rowset", Result.class, "callGroups");
xStream.aliasAttribute(RowCallGroups.class, "groupID", "groupID");
xStream.aliasAttribute(RowCallGroups.class, "name", "name");
xStream.aliasAttribute(RowCallGroups.class, "description", "description");
xStream.addImplicitCollection(RowSetCallGroups.class, "callGroups");
xStream.alias("rowset", RowSetCallGroups.class);
xStream.aliasAttribute(RowSetCallGroups.class, "name", "name");
xStream.aliasAttribute(RowSetCallGroups.class, "key", "key");
xStream.aliasAttribute(RowSetCallGroups.class, "columns", "columns");
xStream.alias("row", RowCalls.class);
xStream.aliasField("rowset", Result.class, "calls");
xStream.aliasAttribute(RowCalls.class, "accessMask", "accessMask");
xStream.aliasAttribute(RowCalls.class, "type", "type");
xStream.aliasAttribute(RowCalls.class, "name", "name");
xStream.aliasAttribute(RowCalls.class, "groupID", "groupID");
xStream.aliasAttribute(RowCalls.class, "description", "description");
xStream.addImplicitCollection(RowSetCalls.class, "calls");
xStream.alias("rowset", RowSetCalls.class);
xStream.aliasAttribute(RowSetCalls.class, "name", "name");
xStream.aliasAttribute(RowSetCalls.class, "key", "key");
xStream.aliasAttribute(RowSetCalls.class, "columns", "columns");
```
任何想法,我如何根据name=
属性的内容进行映射?
答案 0 :(得分:0)
我昨晚无法发布解决方案,我现在就这样做了。
首先:到目前为止,发布所有这些类将超过发布限制。 D.B。
第二:关键是,我的数据布局错误。
解决方案:我必须使用自定义转换器。 “原生”的无法转换该架构。