No problem. I think there's users that might have learned something here
.. ;-).
Werner
Jeff Crump wrote:
> Nevermind, figured it out: my underlying data model was using primitives
> (int) instead of objects (Integer). When I fixed this, and the getter
> returned null, the attribute was not marshalled.
>
> Sorry for the spam.
>
> Jeff
>
> 2008/12/10 Jeff Crump <[EMAIL PROTECTED]>
>
>> Hello,
>>
>> I'm having trouble with optional (i.e., required=false) attributes in my
>> input XML. My Java object looks like this:
>>
>> class MyElement {
>> public Integer val = null;
>> public void setVal(int n) { val = new Integer(n); }
>> public Integer getVal() return val;
>> }
>>
>> The mapping file defines the 'val' field as required=false:
>>
>> <field name="val" type="int" required="false">
>> <bind-xml name="val" node="attribute">
>> </field>
>>
>> With an input document like this:
>>
>> <MyElement/>
>>
>> the unmarshalling of this is working fine -- if 'val' is not provided in
>> the input, the setter method does not get called.
>>
>> My problem is on the marshalling side. When I re-marshall this object into
>> XML, the output contains a 'val' attribute set to 0:
>>
>> <MyElement val="0"/>
>>
>> How can I tell the marshaller to not create this attribute? I'd like the
>> output to be semantically the same as the input, and with this behavior, it
>> isn't.
>>
>> Thanks,
>>
>> Jeff
>>
>>
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email