mark helm wrote:

I need to map an existing XML structure that contains optional empty elements, e.g. <ISBLACK/>

I would like to map this to a Java boolean. E.g.
class MyClass {
private boolean black;
}

If the xml contains the empty element <ISBLACK/>, then the java instance variable should be set to true, otherwise to false.

How would the binding look like?

Mark.



I haven't tried this out, but I think the existing code will handle this if you're a little creative. You should be able to do this either using a custom deserializer or using a set-method. The custom deserializer will be called with a zero-length String if the element is present but empty, so you could just return "true" in this case. The same approach should also work for a set-method taking a String value - if the element is present it'll be called with a zero-length String, at which point you can store the "true". You won't get any call for the case where the element is missing, but you can initialize the variable to the proper state for that case (in your case, "false" is the Java default anyway).

- Dennis

--
Dennis M. Sosnoski
Enterprise Java, XML, and Web Services
Training and Consulting
http://www.sosnoski.com
Redmond, WA  425.885.7197




------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ jibx-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to