docs: def _make_attr_element_from_typeattr(parent, type_attr_i):
      """
          General function to add an attribute element to a resource element.
          resource_attr_i can also e a type_attr if being called from get_tempalte_as_xml
      """
  
      attr = _make_attr_element(parent, type_attr_i.attr)
  
      if type_attr_i.unit_id is not None:
          attr_unit    = etree.SubElement(attr, 'unit')
          attr_unit.text = units.get_unit(type_attr_i.unit_id).abbreviation
  
      attr_is_var    = etree.SubElement(attr, 'is_var')
      attr_is_var.text = type_attr_i.attr_is_var
  
      if type_attr_i.data_type is not None:
          attr_data_type    = etree.SubElement(attr, 'data_type')
          attr_data_type.text = type_attr_i.data_type
  
      if type_attr_i.data_restriction is not None:
          attr_data_restriction    = etree.SubElement(attr, 'restrictions')
          attr_data_restriction.text = type_attr_i.data_restriction
  
      return attr