<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def str_to_v1_str(xml_str):
 """Convert a API v2 XML doc to v1 XML doc. Removes elements that are only valid for v2 and changes namespace to v1. If doc is already v1, it is returned unchanged. Args: xml_str : str API v2 XML doc. E.g.: ``SystemMetadata v2``. Returns: str : API v1 XML doc. E.g.: ``SystemMetadata v1``. """

    if str_is_v1(xml_str):
        return xml_str
    etree_obj = str_to_etree(xml_str)
    strip_v2_elements(etree_obj)
    etree_replace_namespace(etree_obj, d1_common.types.dataoneTypes_v1.Namespace)
    return etree_to_str(etree_obj)