Hi Neeme, Yes, you can do this in JiBX - but you need to use a <structure> reference to the object, rather than a <value> reference. <value> always represents a simple text value in JiBX bindings. Substituting this into your <mapping> gives:
<mapping name="Create" class="Create"> <structure field="object"/> </mapping> Notice that I did not use a name attribute on the <structure>, because the name will actually be determined by the mapping definition for the actual type of the object. The only catch is that using the current 1.1.6 release you need to compile all the bindings at once. In the current 1.2 CVS code it's possible to compile the bindings separately, which is what I suspect you really want to do. That would allow you to compile and bind the classes in core and assemble the jar, then just use that jar for APPLES and ORANGES separately with their own bindings which build on that used for core. I'm trying to work through the documentation of this and the other new 1.2 features so that I can get out a beta release. - 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 Neeme Praks wrote: > Hi, > > Question about fairly advanced JiBX usage. > > I have three projects in different JAR files (names somewhat obfuscated): > * CAI3G core > * CAI3G APPLES > * CAI3G ORANGES > > CAI3G core defines XML "envelope", sample: > <cai3g:Create xmlns:cai3g="http://schemas.company.com/cai3g"> > <cai3g:Object> > <!-- in here we can use some abstract types --> > </cai3g:Object> > </cai3g:Create> > > Inside that "envelope" can be some XML element that core project is not > aware of (declares in schema either ANY element or substitution group - > but I guess this is not important for JiBX). > > This envelope corresponds to Java class: > public class Create { > public Object object; > } > > APPLES and ORANGES use core project and fill in the contents of the > "envelope" (Create class) and hand this object to code in core project > which then is supposed to marshal and unmarshal the full graph. > The end-result XML should look something like this: > > APPLE create: > <cai3g:Create xmlns:cai3g="http://schemas.company.com/cai3g"> > <cai3g:Object> > <Apple xmlns="http://schemas.company.com/apples"> > <Color>Red</Color> > <Taste>Delicious</Taste> > </Apple> > </cai3g:Object> > </cai3g:Create> > > ORANGE create: > <cai3g:Create xmlns:cai3g="http://schemas.company.com/cai3g"> > <cai3g:Object> > <Orange xmlns="http://schemas.company.com/orange"> > <Size>Large</Size> > <Juicy>True</Juicy> > </Orange> > </cai3g:Object> > </cai3g:Create> > > How do I define JiBX binding file so that this case is handled > correctly? I browsed the docs, but couldn't find any obvious answer. > > I imagine that it could work like this: > * in core binding.xml I state that particular XML element can contain > ANY child elements and these should be parsed with root level mappings > * in APPLES and ORANGES projects I define bindings with root level > mappings for concrete wrapped types (Apple and Orange). > * I make these three different binding factories aware of each other > > How do I achieve something like that? Is it possible at all? I just > scrapped XmlBeans in favor of JiBX because this kind of setup seemed > impossible to achieve with XmlBeans. Please tell me it is possible with > JiBX. > > ;-) > > As a starter, I tried (in core): > <mapping name="Create" class="Create"> > <value name="Object" field="object"/> > </mapping> > > This gives me the following error in Eclipse JiBX plugin: > Error: Need deserializer or constructor from string for type > java.lang.Object; on value element at (line 44, col 36, in binding.xml) > > Any pointers appreciated. > > Rgds, > Neeme > > > ------------------------------------------------------------------------- > 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