Yes, you'd need to use a method hook to propagate the data down to the Test instances. You'd also need to store the "current" status value somewhere, and it would take some special handling to do this while keeping all the Test instances in a single list. The way I'd do this would be to use a custom unmarshaller for the List containing all the Test instances, and a separate <mapping> for the Test class. The custom unmarshaller would loop on the <tests> elements and read the status, then loop on unmarshalling Test instances and setting the status value on each instance, adding each to the list. So I don't see any way to meet your criteria of no custom code, but the custom code is at least fairly simple.
- 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 Varghese C V wrote: > <binding> > <mapping name="testsuite" class="TestSuite"> > <structure allow-repeats="true" ordered="false"> > <structure name="tests"> > <collection field="tests" > factory="org.jibx.runtime.Utility.arrayListFactory"/> > </structure> > </structure> > </mapping> > > <mapping name="test" class="Test" value-style="attribute"> > <value name="name" field="name"/> > </mapping> > </binding> > > This binding xml can be used to unmarshall your example xml. I cannot > find a way by which you can propagate the status to the child test > elements without changes to the model and code in jibx's method hooks. > > Interesting problem. Ideas' anyone? > > cheers > Varghese C V > > Bret Gregory wrote: > >> I am evaluating JiBX and am interested in seeing if it can handle a >> scenario that I have had some difficulty with using other XML binding >> tools. >> >> The benchmarks are impressive and alone are a convincing argument to >> use it, but I have been burned by XML-Binding frameworks in the past. >> >> Can anyone show a simple binding that would handle a case like this? >> >> Problem: >> >> Given the following XML, I would like to unmarshall this into 2 >> classes. Can a binding like this be made without writing additional >> code to support it? >> >> TestSuite maps 1:1 to the <testsuite> element. The class contains a >> list of tests which map to the <test> element, however the Test class >> also contains a status which is from the <tests> element, the parent >> element of <test>. >> >> TestSuite >> >> List tests >> >> Test >> >> String name >> >> String status >> >> >> <testsuite> >> >> <tests status=”FAILED”> >> >> <test name=”test1”/> >> >> <test test name=”test2”/> >> >> <test test name=”test3”/> >> >> <test name=”test4”/> >> >> </ tests> >> >> <tests status=”PASSED”> >> >> <test test name=”test5”/> >> >> <test test name=”test6”/> >> >> <test test name=”test7”/> >> >> <test test name=”test8”/> >> >> </tests> >> >> </testsuite> >> >> ------------------------------------------------------------------------ >> >> ------------------------------------------------------------------------- >> 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 >> jibx-users@lists.sourceforge.net >> 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 > jibx-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jibx-users > > ------------------------------------------------------------------------- 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