def split_stable_id(stable_id):
    """
    Split stable id, returning:
        * Document (root) stable ID
        * Context polymorphic type
        * Character offset start, end *relative to document start*
    Returns tuple of four values.
    """
    split1 = stable_id.split('::')
    if len(split1) == 2:
        split2 = split1[1].split(':')
        if len(split2) == 3:
            return split1[0], split2[0], int(split2[1]), int(split2[2])
    raise ValueError("Malformed stable_id:", stable_id)