Bao Trang wrote:
In my java class, I have a boolean and two objects, A and B. If theYou should be able to do this by using a pair of test-methods, one for object A (which just returns the boolean) and one for object B (which returns the logical not of the boolean). Then your binding definition would go something like this:
boolean is set to true, I want the marshaller to output object A in my
XML file. Otherwise, I want the marshaller to output object B.
<mapping ...>
...
<structure name="A" field="aproperty" usage="optional" test-method="testA">
...
</structure>
<structure name="B" field="bproperty" usage="optional" test-method="testB">
...
</structure>
...
There's no way to do this directly, but you can use the above binding fragment and add a post-set method to the containing object binding. The post-set method will be called after that object has been unmarshalled, and you can then set your boolean as "aproperty != null". You can also use the post-set method to check that one and only one of the alternatives was included in the unmarshalled document, if you want (throwing an exception if neither was present or both were present).Conversely, when I'm unmarshalling, if Object A exists, I want my boolean to be set to true. Otherwise if Object B exists in the xml file, I want the boolean to be set to false.
- Dennis
------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ jibx-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jibx-users
