A suggestion -
Shouldn't your models reflect how the xml is laid out?
If you remodel the Profile class be an enclosing class and has a 
reference to a ProfileType abstract class whose concrete instances are 
Traveller & Company then you will find the jibx mappings very straight 
forward to implement.

public class Profile{
    ...
    public ProfileType profileType;
    ...
}

public abstract class ProfileType{...}

public class Traveller extends ProfileType{...}

regards
Varghese C V

gufux wrote:
> Hi,
>
> I have an issue with binding and class inheritance based on an 
> internal element of XML schema. I have the following classes:
>
> ----------------------------------------------------------
> public class Profile {
>     protected UniqueId profileId;
> }
>
> public class Traveller extends Profile {
>     protected TravellerName name;
>     ....
> }
>
> public class Company extends Profile {
>    protected CompanyName name;
>    ....
> }
> ------------------------------------------------------------
>
> and XML messages like that:
>
> 1) <Profile>
>       <UniqueId type="1" />
>        <TravellerName>Davide</TravellerName>
>    </Profile>
> 2) <Profile>
>       <UniqueId type="1" />
>        <CompanyName>IBM</ComapnyName>
>    </Profile>
>
> So I want to use only instances of Traveller and Company depending if 
> in XML inside the <Profile> i have <TravellerName> or <CompanyName>.
> I've tried with abstract classes and "extends" but there isn't a 
> solution because when JibX have to bind the <Profile> it doesn't know 
> the inside element and the correct
> instance depend on that element.
>
> I'have spent many time on this problem and so I would know if it's me 
> that haven't found the right solution or in fact in Jibx simply I 
> can't do that... anyone have any suggestions?
>
> Thanks
>
> Davide.
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> ------------------------------------------------------------------------
>
> _______________________________________________
> jibx-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>   


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to