Hi Johannes,

The only way of handling this type of situation is to have a collection 
of all the SourceVO instances at one point in your binding, then use 
ID/IDREF links to refer to each instance. So it'd end up looking 
something like this:

  <SourceVO id="ID8">
    ...
    <sources>ID1 ID3 ID10 ...</source>
    ...
  </SourceVO>
  <SourceVO id="ID10">
    ...
  </SourceVO>

See the Working with IDs section of the tutorial 
(http://jibx.sourceforge.net/tutorial/binding-collects.html#ids) for 
some details on how to handle this in the binding. Note that you'd 
probably have to use some extension code of your own to convert the 
SourceVOs into this type of structure - you'd basically want to build a 
collection of the closure of all the SourceVOs being marshalled in your 
own code, then have JiBX marshal the constructed collection.

  - 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



Johannes Müller wrote:
> Hello all,
>
> in a Java object called "SourceVO", I have an attribute called "sources", 
> which is a list of "SourceVO"'s. Therefore, each of the list objects contains 
> a list of SourceVO's itself (recursion).
>
> I tried to bind this with the following JiBX mappings, but with these, the 
> binding compiler (v1.1.3) runs into an endless loop.
>
> How can I get the recursive collections bound properly?
>
> <mapping [...]>
>   [...]
>   <collection field="sources" 
> factory="org.foobar.JiBXHelper.sourceVOListFactory" usage="optional">
>     <structure name="source"  map-as="org.foobar.SourceVO" />
>   </collection> 
>   [...]
> </mapping>   
>
>
> <mapping class="org.foobar.SourceVO" ordered="false" allow-repeats="true" 
> abstract="true">                 
>    [...]                                                            
>    <collection field="sources" 
> factory="org.foobar.JiBXHelper.sourceVOListFactory" usage="optional">
>       <structure name="source" map-as="org.foobar.SourceVO" /> </collection>  
>                                                                [...]
> </mapping>
>
> Regards,
>
> Johannes
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> jibx-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>
>   

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to