def split_namespace(tag):
    """ Split a tag into a namespace and a tag
    """
    if tag.startswith('{'):
        ns, tag = tag.lstrip('{').split('}')
    elif tag.count(':') > 1:
        tokens = tag.split(':')
        tag = tokens.pop()
        ns = ':'.join(tokens)
    elif tag.count(':') == 1:
        ns, tag = tag.split(':')
    else:
        ns = None
    return ns, tag
