Hi Matthias, Thanks for the suggestion; actually this is what I did when I started but then I decided to trim down a bit the number of classes by "collapsing" XML types containing only one child tag as <instrument> does.
One of reasons why I like JiBX is indeed the capability of mapping complex xml structures to simpler Java types, a must with the complex schemas I'm dealing with. I will investigate writing my own Marshaller and, in the meantime, create the Instrument class as you suggest. OTOH I still believe that JiBX should not marshal the field at all. Thanks, Andrea. -- Andrea Cisternino, Ferrara, Italy LinkedIn profile: http://www.linkedin.com/in/andreacisternino Blog: http://opificiodigitale.wordpress.com Foto: http://acisternino.smugmug.com 2008/7/30 Matthias Pretzer <[EMAIL PROTECTED]>: > Hi, > > Andrea Cisternino: > >> The problem is that when I unmarshal and immediately marshal a >> document containing the second fragment what I get is the following: >> >> <payment-type> >> <level><code>AVG958294AF</code></level> >> <instrument/> <!-- WRONG --> >> </payment-type> > > The only solution I found is to change your PaymentType class to have an > "instrument" member which in turn a propr member (or whatever you want > to call it). Like this: > > class PaymentType { > String level; > Instrument instrumelt; > } > class Instrument { > String propr; > } > > This way, you can assign PaymentType.instrument a null value and jibx > will omit the element. > > Another way might be to write your own Marshaller. > > best, > > Matthias ------------------------------------------------------------------------- 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 [email protected] https://lists.sourceforge.net/lists/listinfo/jibx-users
