@staticmethod
def parse_id(name):
    """
        Resolves an id from a binary XML file in the form "@[package:]DEADBEEF"
        and returns a tuple of package name and resource id.
        If no package name was given, i.e. the ID has the form "@DEADBEEF",
        the package name is set to None.

        Raises a ValueError if the id is malformed.

        :param name: the string of the resource, as in the binary XML file
        :return: a tuple of (resource_id, package_name).
        """
    if not name.startswith('@'):
        raise ValueError("Not a valid resource ID, must start with @: '{}'"
            .format(name))
    name = name[1:]
    package = None
    if ':' in name:
        package, res_id = name.split(':', 1)
    else:
        res_id = name
    if len(res_id) != 8:
        raise ValueError("Numerical ID is not 8 characters long: '{}'".
            format(res_id))
    try:
        return int(res_id, 16), package
    except ValueError:
        raise ValueError("ID is not a hex ID: '{}'".format(res_id))
