users@jaxb.java.net

Re: jaxb2 and idref

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 14 May 2007 17:23:57 -0700

Francois Le Fevre wrote:
> Dear all,
>
> I have still a difficluty using idref with jaxb2
>
> I have created a xml schema where for instance a list of B and A object
> where B contains a reference to A via idRef. ( see at the end of the
> email )
> But the java generated code is:
> public class B {
>
> @XmlElementRef(name = "a", type = JAXBElement.class)
> protected List<JAXBElement<Object>> a;
> ..
> }
>
> And i would like to precise a "protected List<A> a;" and not "protected
> List<JAXBElement<Object>> a;"
> do i need to use something different from idref ... keyref ... or add
> annotation inforamtion ??
>
> Thanks for all your help.

To differenciate between IDREFS and list of elements whose type is ID,
JAXBElement is necessary.

I'm sympathetic, but there's no way around this.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com