The requirement is to skip field when its empty. eg -
<segment name="seg1" class="com.company.bean.segmentBean" xmlType="none">
<field name="field1" xmlName= "fieldXml1" xmlType="attribute" maxLength="7" />
<field name="field2" xmlName= "fieldX2l1" xmlType="attribute" maxLength="1" typeHandler="Handler" />
</segment>
Lets assume that field2="". As the value of field2 is "". I would like to have the field skipped in segment. Basically the end result XML shouldnt display field2 as its empty("").
You need the
lazyattribute on field2. As stated in the Reference GuideThis will make
field2 = nulland by default, most XML libraries will not output any null elements,BeanIOincluded.Try this for field2:
Most of the time, I also combine
lazywithtrim. From the docs: