This week's book giveaway is in the Java in General forum. We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line! See this thread for details.
Castor: How to map list items within a "parent" list element?
posted 10 years ago
I am trying to map a List but have yet to work out the correct Castor mapping. When I let Castor auto-complete the class which contains the List I get all of the elements of the list at the same level. For example if my object contains a List of two elements I will get XML which looks like the following:
I get the first example XML whether or not I use the <field> element in the <class> mapping element above.
The List member of the class I'm mapping is actually a List<E>, in that it is a List of objects of a class which is also mapped in the mapping.xml. Maybe Castor doesn't yet support generics, but I haven't seen anything to that effect in the documentation.
Also I have tried using bind-xml but the bind doesn't have the effect of nesting all of the list item elements within a "parent" list element, which is what I'm trying to achieve, instead it renames the list elements to whatever is specified as the bind-xml name.
Can someone steer me in the right direction? Thanks in advance for any suggestions!