users@jaxb.java.net

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

From: Chris O'Connell <oconnell_at_gorillachicago.com>
Date: Fri, 7 Sep 2007 12:15:09 -0500

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