users@jaxb.java.net

Re: How to unmashal the xml to a sub class?

From: James Mao <james.mao_at_iona.com>
Date: Mon, 10 Sep 2007 10:09:00 +0800

Thanks, for the reply, what's next, pass the objectFactory to the
jaxbContext?

So next time, jaxb will convert all the <meta/> to subMeta class? what
if there's a sub2Meta which also extends Meta,
I mean it's not just subMeta, its' about the generate sub class.

Is there other ways out, programatically?

Thanks,
James

> Extend the ObjectFactory and override the 'getMeta' method so that your
> implementation looks like this:
>
> public Meta getMeta(){
> return new SubMeta();
> }
>
> -----Original Message-----
> From: James Mao [mailto:james.mao_at_iona.com]
> Sent: Friday, September 07, 2007 5:18 AM
> To: users_at_jaxb.dev.java.net
> Subject: How to unmashal the xml to a sub class?
>
> Hi,
>
> I have a xml file
>
> <meta xmlns="http://foo.com">
> <uid>abc</uid>
> </meta>
>
>
> I have Meta.java which is generated by Jaxb2
>
> I also have a SubMeta which extends the Meta, but it's a POJO, without
> any jaxb annotation, and is created manually
>
> public class SubMeta extends Meta {
> int foo;
> // getter/setter ...
> }
>
>
> Is it possible to unmarshal the xml file to generate the object of the
> SubMeta? and How?
>
>
> Thanks in advance
> James
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>