def get_factory_object_name(namespace):
    "Returns the correct factory object for a given namespace"
    
    factory_map = {
        'http://www.opengis.net/kml/2.2': 'KML',
        'http://www.w3.org/2005/Atom': 'ATOM',
        'http://www.google.com/kml/ext/2.2': 'GX'
    }
    if namespace:
        if factory_map.has_key(namespace):
            factory_object_name = factory_map[namespace]
        else:
            factory_object_name = None
    else:
        # use the KML factory object as the default, if no namespace is given
        factory_object_name = 'KML'
    return factory_object_name
Returns the correct factory object for a given namespace