java - xstream does not apply dynamic binding when converting XML to Javabean -


i using xstream convert xml javabean. here's example of xml trying process:

<productlist>     <a>        <name>a1</name>     </a>     <a>        <name>a2</name>     </a>     <b>        <name>b1</name>     </b>     <b>        <name>b2</name>     </b> </productlist> 

i used abstact product , set , b 2 subclasses of it. works when want use convert javabean xml, use list , add instances of or b it. xstreamalias works fine, too.

however, when need use transfer xml javabean, not work. seems xstream cannot automatically identify subclass , put list.

now have create class productlist, put lists list , list , use @xstreamimplicit ignore list names. work, if new subclasses c created, have modify productlist , add list. surely not way of coding.

is there better solution of doing this? using annotations or what?


Comments