Hi Anshuk,

If it's just a matter of String fields getting set to "" rather than 
null, you can set this as a default value for the field (default=""). If 
you do this JiBX should ignore the fields when marshalling. You could 
also define your own serializer method (see 
http://jibx.sourceforge.net/binding/tutorial/binding-extend.html#serdeser) 
which stripped off whitespace, and use this in combination with 
default="" so that either an empty string of one consisting only of 
whitespace would match the default (the default value you supply is 
compared with the result returned by the serializer).

You can't have the serializer method return null to indicate the value 
can be skipped when marshalling, though, since the result has to be 
non-null.

  - Dennis

Dennis M. Sosnoski
XML 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



Anshuk wrote:
> Hello,
>
> I have a small issue here, when I am trying to marshall objects to XML, in
> some case the member variables of the objects gets an empty string or space
> value. this field is metioned optional in the binding file; since the empty
> string value is not null, an empty element is created in the XML. This is
> correctly done by JIBX as it is not null, it creating an empty element.
>
> My requirement is not to create this element, if the value is empty or space
> value. I think this is feasible by using a custom serializer.
> can anyone help me in getting some pointers or some examples.
>
> Any help is really appreciated.
>
> Anshuk
>   

------------------------------------------------------------------------------
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to