The elements in a data template may contain attributes. If you want to fill an attribute value dynamically, you must create a value for it in the corresponding rule, for example:
If the transformation rule contains an XPath expression that evaluates to a value for the attribute, then the value is overwritten by the evaluation result (deleted if the result is empty).
If the transformation rule does not contain an XPath expression that evaluates to a value, then the value is left as it is in the data template (no value or static value).