[Simple-support] Deserialisation of XML document with multiple namespaces
Brought to you by:
niallg
|
From: Dave M. <dav...@gm...> - 2011-05-09 16:58:58
|
Hi, I am attempting to read an xml document which has common element names across namespaces. <content> <element> <name/> <xy1:sub_element xmlns:xy1="http://www.xxx.com"> <xy1:detail_1/> <xy1:detail_2/> </xy1:sub_element> <xy2:sub_element xmlns:xy2="http://www.yyy.com"> <xy2:something_else/> <xy2:something_different/> </xy2:sub_element> </element> </content> I have tried many ways to resolve this, but come up with errors which ever way I go, e.g. duplicate annotation in the java class public class XmlElement { private String name; @Element(name="sub_element") @Namespace(prefix="xy1", reference="http://www.xxz.com)") private ThingOne thingOne; @Element(name="sub_element") @Namespace(prefix="xy2", reference="http://www.xxz.com)") private ThingTwo thingTwo; } Any ideas as to how this should be done? If I comment out the 'thingTwo' sub_element, it fails with an exception indicating that the element 'sub_element' has been declared twice, which seems to indicate it is ignoring the namespace? Thanks in anticipation of a solution. Dave Mellors |