Hi Dennis,

Thanks for the response. I eventually gave up on the same element name
for all the different subscription types. I couldn't get any sort of
multiple levels of extends to work, so resorted to cut'n paste for the
six subclasses that I have currently. I'll look to try out the new
feature from CVS HEAD and give you some feedback at some point.

Cheers,

James

On 01/11/05, Dennis Sosnoski <[EMAIL PROTECTED]> wrote:
> Hi James,
>
> You want to use many different types of subscriptions interchangeably
> within your collection while using the same element name for all types.
> JiBX doesn't currently support this directly at present, because there's
> no way for it to know which type of class to create when unmarshalling.
> That should change in the future - there's a schema feature called type
> substitution which does basically what you're requesting (though it
> requires the "type" attribute to be in the schema instance namespace),
> and it's definitely on the list for JiBX 2.0.
>
> There's one way to do this now, using a custom marshaller/unmarshaller
> that makes use of abstract mapping information, but it may be more work
> than you want to try. Another alternative is to use different element
> names for the different subclasses, rather than a type="xxx" attribute
> to distinguish between them. I recently enhanced the CVS code to support
> multiple levels of extends="..." mappings, which is what you'd want to
> make this work cleanly.
>
>   - Dennis
>
> James Abley wrote:
>
> >On 21/10/05, Mocky Habeeb <[EMAIL PROTECTED]> wrote:
> >
> >
> >>I used ArrayList in this example, but arrays should work fine. Is this
> >>at all similar to the type of output you are looking for?
> >>
> >><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> >><userData>
> >>    <name>Mocky</name>
> >>    <joiningDate>1994/10/10</joiningDate>
> >>    <subscriptions>
> >>        <subscription createdDate="Fri Oct 21 08:36:22 EDT 2005"
> >>type="credit"/>
> >>        <subscription createdDate="Fri Oct 21 08:36:22 EDT 2005"
> >>type="position"/>
> >>        <subscription createdDate="Fri Oct 21 08:36:22 EDT 2005"
> >>type="credit"/>
> >>    </subscriptions>
> >></userData>
> >>
> >>
> >>
> >
> >Pretty much. I was looking for something like this:
> >
> ><?xml version='1.0' encoding='UTF-8'?>
> ><userData>
> >    <name>Test User</name>
> >    <joiningDate>2005-10-19T00:00:00</joiningDate>
> >    <subscriptions>
> >        <subscription type="subscription">
> >            <createdDate>2005-10-19T00:00:00</createdDate>
> >        </subscription>
> >        <subscription type="credit">
> >            <createdDate>2005-10-19T00:00:00</createdDate>
> >                <creditRenewalDate>2005-11-19T00:00:00</creditRenewalDate>
> >        </subscription>
> >    </subscriptions>
> ></userData>
> >
> >Obviously, I've not got the attribute mappings in place yet, since I'm
> >struggling to get it to marshall the subclasses.
> >
> >I'm not sure what would be the best format, so here's the four classes I 
> >have:
> >
> >...
> >
> >
> >
> >
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the JBoss Inc.
> Get Certified Today * Register for a JBoss Training Course
> Free Certification Exam for All Training Attendees Through End of 2005
> Visit http://www.jboss.com/services/certification for more information
> _______________________________________________
> jibx-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to