I think that's just the way JiBX works.

You might consider a workaround of creating a new setter method
setValueIfNull() that does nothing if the value is already set.

-Archie


On Thu, Dec 12, 2013 at 10:49 AM, Vincent Fumo <vfumo.w...@gmail.com> wrote:

>  I've got 2 xml files to unmarshall using jibx. They have identical
> structure with one exception : one of the elements has a different
> attribute name for the same property. I'd like to use the same binding but
> I'm getting behavior that I don't understand. Can anyone help?
>
> A Generalization of the files:
>
> File 1
>
> <A><B name="foo"/></A>
>
> File 2
>
> <A><B key="foo"/></A>
>
> My binding looks something like this :
>
> <structure name="A" ordered="false" flexible="true" usage="optional">
>   <structure name="B" ordered="false" flexible="true" usage="optional">
>     <value style="attribute" name="name" set-method="setValue" 
> get-method="getValue" usage="optional"/>
>     <value style="attribute" name="key" set-method="setValue" 
> get-method="getValue" usage="optional"/>
>   </structure>
> </structure>
>
> Note that I've used 2 value elements calling the same accessors and set
> them both to optional.
>
> The issue is that when I run for file 1 my property is set to null, when I
> run for file 2 my property is set correctly ("foo").
>
> My guess is that jibx is calling both of these value elements even though
> the attributes are set at optional. Is this a bug in jibx? Am I doing
> something wrong?
>
> Any ideas would be greatly appreciated. Thanks.
>
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics
> Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>
>


-- 
Archie L. Cobbs
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to