Hi Jon, A custom unmarshaller should allow you to do what you want. What you'd need to do is make the type returned by the unmarshaller the greatest common denominator of the FieldCode and FieldCodeType classes. Then in the unmarshaller code, avoid creating the unmarshalled object until you read the <NameValuePair> element and can tell the appropriate type. That's the approach in a nutshell.
There are some other tricks you can use to make your code simpler. For instance, if one class extends the other you can use an abstract <mapping> for the base class handling and invoke that from within your own unmarshaller code. That uses some features added in 1.1 to support looking up abstract marshaller/unmarshallers. - 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 Jon Kosmoski wrote: > > Hi, I have XML that looks like: > <FieldValue> > <NameValuePair type="CodeType" ...> > ... > </FieldValue> > > In Java I have an abstract FieldValue base class and subclasses > FieldCode and FieldCodeType. > > If during unmarshalling, type="CodeType" I want to unmarshal the > FieldValue element into an instance of FieldCodeType and if > type equals anything else I want to unmarshal into an instance of > FieldCode. During marshalling I want both subclasses to marshal > to a FieldValue element. The marshalling part is easy (just define > mappings for the subclasses), but I assume I will > need to use a custom unmarshaller, but can't figure out exactly how to > make this work or if this is even possible. > Any help would be much appreciated. Thanks, - Jon > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > ------------------------------------------------------------------------ > > _______________________________________________ > jibx-users mailing list > jibx-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jibx-users > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users