Я пытаюсь использовать XStream для сопоставления XML с Java-объектом. Но здесь есть одна ошибка.
public class Concepts {
List<Concept> conceptList = new ArrayList<Concept>();
}
public class Concept {
String id;
String name;
String table;
List<Child> childList= new ArrayList<Child>();
}
public class Child {
String id;
String name;
String childTable;
String rel;
}
xml
<?xml version="1.0" encoding="UTF-8"?>
<concepts>
<concept id="1234" name="student" table="student">
<childList>
<child id="" name="Address" childTable="address" rel="one-to-one"/>
<child id="" name="Score" childTable="score" rel="one-to-many"/>
</childList>
</concept>
<concept id="12343" name="address" table="address"/>
<concept id="123433" name="store" table="score"/>
</concepts>
мое отображение
xstream.alias("concepts", Concepts.class);
xstream.alias("concept", Concept.class);
xstream.alias("child", Child.class);
xstream.useAttributeFor("name", String.class);
xstream.useAttributeFor("id", String.class);
xstream.useAttributeFor("table", String.class);
xstream.useAttributeFor("childTable", String.class);
xstream.useAttributeFor("rel", String.class);
// collection
xstream.addImplicitCollection(Concepts.class, "conceptList","concept", Concept.class);
xstream.addImplicitCollection(Concept.class, "childList", "childList", Child.class); //bug
В последней строке есть ошибка. это не может отобразить детский массив. Я не знаю, где ошибка.
Спасибо.