Can libxmp be forced to register a namespace prefix when it won't take a suggested prefix?
Question: I'm handling xmp data with [python-xmp-
toolkit](https://code.google.com/p/python-xmp-toolkit/), which is a python
wrapping of the exempi C library.

We have an in-house namespace uri that we use in this data beginning with
"ns:oursite.com" rather than "http:oursite.com" or something else similar.
When I try to use the [register_namespace
method](http://www.spacetelescope.org/static/projects/python-xmp-
toolkit/docs/reference.html#libxmp.core.XMPMeta.register_namespace) to plug in
our namespace like this:

> new_xmp.register_namespace("ns:oursite.com/stuff", "foo")

it spits back a default "ns2:" prefix indicating that it refuses to register
the prefix I suggested.

I imagine it's doing some sort of validation on the uri name. Is there any way
to force around this? I have a hard time deducing what to do in this code
since it is a wrapping of C.


Answer: There may be another namespace registered under the same prefix but with a
different URI. Exempi allows neither duplicate namespaces nor duplicate
prefixes, unfortunately, and this is a limitation of the underlying Adobe XMP
SDK.

I found a workaround you could try to confirm it. The Exempi library can be
reloaded through the Python bindings, but there is a very small amount of time
(~100µs for me) during which another thread accessing Exempi _will_ crash.
Just run :

    
    
    from libxmp import exempi
    
    # Register a test namespace
    exempi.register_namespace("http://test.com/test", "test")
    
    # Release Exempi. Any XMP object initialized *before* this will be
    # invalid and will segfault the interpreter...
    exempi.terminate()
    
    # Exempi is not initialized there, the Python interpreter will segfault
    # if it is used. We have to call init() before being able to use it again.
    exempi.init()
    
    # Now you can register another URI with the same prefix
    exempi.register_namespace("http://test.com/test/add", "test")
    

