Hi Mike,

You'd need to use a custom unmarshaller to handle this, since you want 
to apply different unmarshallings depending on the attribute value. The 
actual details of the unmarshalling could be handled by abstract mapping 
definitions, and your custom unmarshaller would then need to decide 
which one to invoke and delegate to that (by getting the appropriate 
unmarshaller instance from the unmarshalling context).

It's much easier to do this using distinct element names, of course, and 
it's generally also easier to work with documents using distinct element 
names with other XML tools. XML schema, for instance, has no way to 
represent the type of structure you're describing. So if your XML is 
going to be used by any other applications the separate elements 
approach may be best.

  - Dennis

Dennis M. Sosnoski
SOA and Web Services in Java
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117



Mike Watson wrote:
> Hi,
>
> I'm attempting to create a binding where two objects in my class
> hierarchy (both subclasses of the same base class) share the same
> binding.
>
> The problem I'm having is seeing how this would work with the
> unmarshalling? Do I need to use a factory to do this or can I do it
> "out of the box"?
>
> Ideally my XML would look something like this:
> <Fruit type="Orange">
> ...
> </Fruit>
> <Fruit type="Banana">
> ...
> </Fruit>
> (I'd prefer this format of XML instead of <Orange>...</Orange)
>
> Where type=Orange might contain an element that is specific to an
> orange and type=Banana might contain an element that is specific only
> to a banana.
>
>
> If someone can tell me how to do this it would be greatly appreciated.
>
> Thanks in advance,
>
> Mike.
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>
>   

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to