If you define a data connection using an XML Schema you can specify a minOccur="0" attribute to allow an element to be omitted from the resulting XML. So an XML Schema element defined as;
<xs:element name="preferredContactMethod" type="preferredContactMethodType" minOccurs="0"/>
Will produce a data connection description of;
<preferredContactMethod dd:minOccur="0" dd:nullType="exclude"/>
And the resulting XML will not contain a preferredContactMethod element if the value is null.
It is the nullType="exclude" attribute that controls the handling of the empty element. However, Designer only sets this attribute on simple types. If the minOccurs="0" is on an element that contains child elements or an attribute (that is complex types) then the nullType="exclude" attribute is not added to the data connection description, which can cause the resulting XML to fail schema validation.
This macro will go though the form data description and add the missing nullType="exclude".
Here is a sample form that shows the differences, ComplexTypeNullTypeExclude.pdf. The same fields are duplicated with the first set having the default behaviour and the second set that has been updated by this macro.
And here is the macro, AddNullTypeExcludeToComplexTypes.zip. Extract the files to the macros directory of your Designer ES3 (or later) install and you will now get a "Add dd:nullType="exclude" to complex types" option in the Tools ... Macros menu. (In Designer ES2 you need to extract the files to the Scripts directory of your install and the menu option will be AddNullTypeExcludeToComplexTypes.