users@jaxb.java.net

Re: jaxb annotation in xsd file

From: Felipe Gaúcho <fgaucho_at_gmail.com>
Date: Wed, 24 Sep 2008 09:39:58 +0200

You can import and/or include XSD inside another ones, and use
abstract attributes to establish the hierarchy...

the WSDLs of my project are formed by half dozen XSD files, and it
works fine......


On Wed, Sep 24, 2008 at 9:33 AM, Maciej Zubala <maciej.zubala_at_gmail.com> wrote:
>
>
> 2008/9/23 Wolfgang Laun <wolfgang.laun_at_gmail.com>
>>
>> There is no way to achieve this with annotations. If you need additional
>> subclasses of classes derived from your schema, why don't you extend the
>> schema?
>>
>> If you describe your original problem, perhaps there is a better solution.
>>
>> On 9/23/08, Maciej Zubala <maciej.zubala_at_gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> I've got problems with inheritance in jaxb and I find on some forums that
>>> to solve my problem I need to annotate one class with XMLSeeAlso annotation.
>>> Unfortunatelly I cannot do it in java code generated from xsd, so here is my
>>> question: is it posible to put this annotation in xsd file so that xjc will
>>> annotate a java class automatically for me ??
>
>
> This is rather long story but I'll try to make it short ;)
> I've got complicated hierarchy of types defined in xsd many (each type has
> lots of attributes and always inherits from some other type). XSD files are
> spread around many maven projects and I use maven plugins to generate java
> classes from xsd.
> These types are used as params in web services methods and here the problem
> starts. I've got some method that takes a parameter of type X. Type Y
> inherits from X so I can pass an instance of Y to this method.
> Unfortuyantely my web service client in this case only serializes attributes
> defined in X while it should also serialize attributes defined in Y as
> passed object is instance of Y.
> I've read somewhere out there that to solve this it's enough to annotate X
> as follows:
>
> XMLSeeAlso(value={Y.class})
>
> XJC in this particular case does not place this annotation itself ;/
> Unfortunatelly I cannot do it cause in my case X and Y are defined in
> separate maven projects. Project where Y is defined depends on project where
> X is defined. To place above annotation I would have to make prohect with X
> depend on project wit Y and I would get cyclic dependency.
> That is why I was wondering if it is possible to put that annotation in xsd
> so I don't have to care about dependencies.
>
> If you know any possible solution or have any suggestion please share it
> with me.
> I hope I explained everything clear.
>