def _build_message_elements(id_messages):
    """
    Helper function to build the messages into a list XML elements in the form
    of string literals.

    :param id_messages: The list of message dictionaries to go through to
        assemble the XML from.
    :type id_messages: iterable
    :return: Returns the list of string'ified XML entries to be written to
        the messagesCatalog.xml file.
    :rtype: list [str]
    """
    lines = []
    for id_message in id_messages:
        try:
            lines.append(
                '<message code="{message_code}"\n'
                '         level="{level}"\n'
                '         module="{reference_filename}" line="{line_number}"\n'
                '         args="{keyword_arguments}">\n'
                '{message}\n'
                '</message>'
                .format(**id_message)
            )
        except Exception as ex:
            print(ex)
    return lines