|
When trying to do a fromXML() with an element with 2 addImplicitCollection
and the first element is empty, the firs type elements are created into the second element list.
this is an example of problematic XML:
<test>
<basePath>C:/WrkFld/ChkOut_mlatorre/Batch Test/Base</basePath>
<projectPath>C:/WrkFld/ChkOut_mlatorre/Batch Test</projectPath>
<file name="a.txt"/>
<file name="b.txt"/>
<dataBase name="a.txt">
<select>A,B,C</select>
<from>Table1, Table2</from>
</dataBase>
<dataBase name="b.txt">
<select>*</select>
<from>Table</from>
<where>a>b</where>
</dataBase>
</test>
the root element is defined like this:
public class XMLTest {
private String basePath;
private String projectPath;
private List<XMLFile> files;
private List<XMLDataBase> dataBases;
}
and this is the xstream "configuration":
xstream = new XStream();
xstream.alias("test", XMLTest.class);
xstream.addImplicitCollection(XMLTest.class, "files");
xstream.addImplicitCollection(XMLTest.class, "dataBases");
xstream.alias("dataBase", XMLDataBase.class);
xstream.alias("file", XMLFile.class);
xstream.useAttributeFor(XMLFile.class, "name");
xstream.useAttributeFor(XMLDataBase.class, "name");
Expected result:
2 XMLDataBase Objects with their data saved into the dataBases List.
2 XMLFile Objects with their name saved into the files List.
Obtained result:
2 XMLDataBase Objects with their data saved into the dataBases List. (OK)
2 XMLFile Objects with their name saved into the dataBases List. (NOT OK)
empty files List. (NOT OK)
|