Hello Dennis, thanks for your reply.
If I understand you correctly, this would mean that there had to be a finite set of possible SourceVO structures that are known in advance to implement this. But the set of possible SourceVO-structures is infinite and not known in advance. If you imagine the recursive List<SourceVO> structure as a tree, then all possible trees shall be mapped from and to XML, a flat tree consisting of one root element with 128 direct child-SourceVO's just as well as a highly complex tree with thousands of SourceVO-nodes and dozens of levels, with every single SourceVO having different amounts of child-SourceVOs, for instance. Is this possible with JiBX? Regards, Johannes -------- Original-Nachricht -------- Datum: Mon, 05 Mar 2007 19:23:19 +1300 Von: Dennis Sosnoski <[EMAIL PROTECTED]> An: JiBX users <[email protected]> CC: Betreff: Re: [jibx-users] Handling recursive collections: How? > 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 -- ======================================= Johannes Sebastian Agilo Müller Eburonenstr. 19 50678 Köln Germany Mail: [EMAIL PROTECTED] Web/GnuPG key: http://www.jsam.de ======================================= ------------------------------------------------------------------------- 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
