import re


def rename_class(classe, class_xml, script):
    """
    Prefix class name or reference with script

    :param classe: The class 
    :param class_xml: The class XML
    :param script:  The LGR script
    :return: Updated class name, updated class XML
    """
    new_class_name = script + '-' + classe.name

    class_xml = re.sub(r'name="([^:"]+)"', r'name="{}-\1"'.format(script), class_xml)
    class_xml = re.sub(r'by-ref="([^"]+)"', r'by-ref="{}-\1"'.format(script), class_xml)
    # ignore tags containing ':'
    class_xml = re.sub(r'from-tag="([^:"]+)"', r'from-tag="{}-\1"'.format(script), class_xml)

    return new_class_name, class_xml