This code:
println(new XStream.toXML(List(1,2,3)))
produces this XML:
&
There is only one instance of an empty list, which is the object Nil.
Not seconds after posting the question, the answer came to me, here is a working implementation of unmarshal:
def unmarshal( reader: HierarchicalStreamReader, context: UnmarshallingContext ) = {
var list : List[_] = Nil
while (reader.hasMoreChildren()) {
reader.moveDown();
val item = readItem(reader, context, list);
list = list ::: List(item) // be sure to build the list in the same order
reader.moveUp();
}
list
}