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