JAXB with similar elements and prefixed names

khachdatinh

New Member
Today, I tried to map the following structure with JAXB to Java code. The problem is, the XML structure is given and has the following drawback:The object details data1, data2, ... are all the same for the different objects, so it would be very nice to create a super class. Unfortunately, the elements are prefixed with the names of the type dog, cat, ...Is there an elegant way to map this with JAXB annotations, without code duplication?\[code\]<objects> <dog> <dog_data1>...</data1> <dog_data2>...</data2> <dog_data3>...</data3> </dog> <cat> <cat_data1>...</data1> <cat_data2>...</data2> <cat_data3>...</data3> </cat></objects>\[/code\]
 
Back
Top