users@jaxb.java.net

Re: jaxb annotation in xsd file

From: Felipe Gaúcho <fgaucho_at_gmail.com>
Date: Wed, 24 Sep 2008 10:31:59 +0200

well, the behavior seems correct..

if you declare:

class X {}
class Y extends X {}

and then call a method declared method(X x) with an instance of Y,
only the X attributes will be visible inside the method.. that's
expected....

If you can modify this concept through an annotation, I really don't
know.. I will follow your thread to see if it is possible.. (IMHO, it
is not supposed to be allowed )


On Wed, Sep 24, 2008 at 10:25 AM, Maciej Zubala <maciej.zubala_at_gmail.com> wrote:
>
>
> 2008/9/24 Felipe Gaúcho <fgaucho_at_gmail.com>
>>
>> "X and Y are defined in separate maven projects. Project where Y is
>> defined depends on project where X is defined..."
>>
>> So, class X extends Y, right ?
>
> No Y extends X ;) so the code looks like that:
>
>>
>> or:
>>
>> <xsd:complexType name="X">...</xsd:complexType..> - this is defined in
>> some other xsd but is imported to the xsd with definition below:
>>
>>
>> <xsd:element name="Y">
>> <xsd:complexType>
>> <xsd:complexContent>
>> <xsd:extension base="someOtherNamespace:X">
>> <xsd:attribute name="bbb"
>> type="xsd:string" use="required" />
>> </xsd:extension>
>> </xsd:complexContent>
>> </xsd:complexType>
>> </xsd:element>
>
>
>>
>> reading your previous post, it seems the both type are declared
>> independently and you are trying to establish the hierarchy by an
>> external annotation. Is it correct ? if yes, something is wrong in the
>> project design (or dependencies).. and I am pretty sure it is forced
>> by some special condition you will need to face...
>
> No I'm trying to establish the hierarchy just right by using code simmilar
> to the one above. The problem is that I've got a web service method like
> that:
>
> void someMethod(X x);
>
> Of course I can pass Y to this method cause in generated java classes Y
> extends X. At the compilation level everything is fine but when I run it I
> see on the debug console of web service client that when calling this method
> it treats passed object of type Y as if it was object of type X. In other
> words I get no polymorphic behaviour ;) I've read that to get desired
> behaviuor I have to complete generated code like that:
>
> @XMLSeeAlso(value={Y.class}) -- this is what I have to add on my own
> class X {
> }
>
> class Y extends X {
> }
>
> Unfortunatelly I cannot do this cause X and Y are in different maven
> projects and project Y depends on project X. To be able to add this
> annotation I would have to add dependency the other way round so that X
> depends on Y.
>
> Do you understand the problem now ??
>