If you do not want to write some empty element, you can use “Write null element” property. This setting is available after clicking on some element in Mapping window.
And regarding your first question, what exactly are you trying to do? Where are you specifying the attributes and how should the result look like? If your attribute does not have the same name as metadata field, you can map it specifically with the arrow.
You are right, if binding is done on parent element, static attributes are saved even if element is empty. This behavior is correct. It is inconvinient in your case but there is an option how to prevent the empty element from appearing in output file.
The easiest way is to set filter expression on binding to something like !isnull($in.0.address_line_1). See my example graph nr. 1 for more details. However, this solution has one flaw - there is a bug (https://bug.javlin.eu/browse/CLO-1042) preventing you from making such conditions on data from input ports other than 0. If you do not need such expression, you can use this procedure.
The second option is more time-consuming but it does not require filter expression. You have to create one edge for each child element. See my example graph nr. 2 for more details.
I hope you will find at least one of the examples useful.
If everything goes well, this fix will be a part of our next 3.5.M1 release. But your regexp is a nice workaround for now.
If you mean StructuredDataWriter, I can’t see any easy way. Would not be easier if you switched input edges on XMLWriter? Is it possible in your graph?