You will have to use a Visitor for this. This will allow you to apply namespaces without the use of annotations. There are examples of Visitors in the test cases and in the tutorial.
--- On Mon, 9/5/11, Dave Mellors <dav...@gm...> wrote:
> From: Dave Mellors <dav...@gm...>
> Subject: [Simple-support] Deserialisation of XML document with multiple namespaces
> To: sim...@li...
> Received: Monday, 9 May, 2011, 9:43 AM
> 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
>
>
>
> ------------------------------------------------------------------------------
> WhatsUp Gold - Download Free Network Management Software
> The most intuitive, comprehensive, and cost-effective
> network
> management toolset available today. Delivers lowest
> initial
> acquisition cost and overall TCO of any competing
> solution.
> http://p.sf.net/sfu/whatsupgold-sd
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|