当libxmp不使用建议的前缀时,是否可以强制它注册名称空间前缀?

2024-06-08 09:31:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我用python-xmp-toolkit处理xmp数据,这是exempic库的python包装。你知道吗

我们有一个内部名称空间uri,我们在这个数据中使用它,以“ns:我们的网站“而不是”网址:oursite.com“或者其他类似的东西。当我尝试使用register_namespace method插入我们的名称空间时,如下所示:

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

它抛出一个默认的“ns2:”前缀,表示它拒绝注册我建议的前缀。你知道吗

我想它正在对uri名称进行某种验证。有什么办法可以强迫你改变吗?我很难推断在这段代码中要做什么,因为它是C语言的包装


Tags: 数据名称comregister网站空间urinamespace
1条回答
网友
1楼 · 发布于 2024-06-08 09:31:08

可能有另一个命名空间在同一前缀下注册,但具有不同的URI。不幸的是,Exempi既不允许重复的名称空间,也不允许重复的前缀,这是底层adobexmpsdk的一个限制。你知道吗

我找到了一个解决办法,你可以试着确认一下。Exempi库可以通过Python绑定重新加载,但是在很短的时间内(对我来说大约100µs),另一个访问Exempi的线程将崩溃。快跑:

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")

相关问题 更多 >