Hi Jon, There's one way I can think of to get the behavior you want, but it's not automatic - mostly because what you want is a very unusual sort of behavior, effectively merging data values from the XML document into existing structures.
What you can do is to build on the "default" behavior of JiBX by using an add method for the collection of sub-objects. In that add method, rather than just adding the supplied object to the collection you could first check for an existing instance of the sub-object, and if found you could do an update which would copy all non-null fields of the unmarshalled sub-object across to the existing instance. That way you'd update any values which were specified in the XML, while keeping everything else unmodified. You could also write a custom unmarshaller, which would look at the element representing the sub-object and check for an existing instance. If an existing instance was found you could gen pass that on to JiBX for the actual unmarshalling. However, this approach would mean that values which were not specified in the XML would be overwritten with their default values (null in the case of object references), which doesn't sound like what you want. - 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 Little wrote: > Hey People > > Am still having trouble resolving the below issue. > > Does anyone have any advice or pointers at all? > > Cheers for your help > > Jon > > Jon Little wrote: >> Hi >> >> I have an object structure where the root object contains several >> collections of sub-objects. >> >> The operation that we do most often is given an existing object, the >> incoming XML alters/updates attributes of the root or sub-objects in >> one of the contained collections. >> >> This is done by calling ((IUnmarshallable) target).unmarshal(umc); >> where target is the existing and instantiation root object. >> >> If the XML updates attributes of the root then there are no issues. >> >> If the XML update adds new objects the one of the collections then >> there are no issues. >> >> If the XML updates attributes of a sub-object in one of the contained >> collections then this is were problems begin. Upon unmarshalling Jibx >> creates a new object which is then added to the appropriate >> collection. _Rather_ than updating the existing sub-object in the >> appropriate collection. >> >> Can anyone point me in the right direction for resolving this issue? >> >> Thanks >> >> Jon >> >> > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > 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