java - 在 AllegroGraph 中注册命名空间(缺少注册的命名空间。)

标签 java allegrograph

我在 AllegroGraph 中注册命名空间时遇到问题。

我的Java代码(程序1):

AllegroGraphConnection agc = new AllegroGraphConnection();
 agc.enable();

 AllegroGraph ag = agc.create("test", AGPaths.TRIPLE_STORES);

 AGUtils.printStringArray("AG Namespaces (initially):", ag.getNamespaces());

 ag.registerNamespace("foaf","http://xmlns.com/foaf/0.1/");
 ag.registerNamespace("dc", "http://purl.org/dc/elements/1.1/");
 ag.registerNamespace("dct", "http://purl.org/dc/terms/");
 ag.registerNamespace("exif","http://www.w3.org/2003/12/exif/ns#");
 ag.registerNamespace("prf", "http://www.openmobilealliance.org/tech/profiles/UAPROF/ccppschema-2007511#");

 AGUtils.printStringArray("AG Namespaces (registed):", ag.getNamespaces());

运行,结果(程序1):

AG 命名空间(初始):
0:rdf
1:http://www.w3.org/1999/02/22-rdf-syntax-ns#
2:rdfs
3:http://www.w3.org/2000/01/rdf-schema#
4:猫头鹰
5:http://www.w3.org/2002/07/owl#

AG 命名空间(已注册):

  0: rdf
  1: http://www.w3.org/1999/02/22-rdf-syntax-ns#
  2: rdfs
  3: http://www.w3.org/2000/01/rdf-schema#
  4: owl
  5: http://www.w3.org/2002/07/owl#
  6: foaf
  7: http://xmlns.com/foaf/0.1/
  8: dc
  9: http://purl.org/dc/elements/1.1/
  10: dct
  11: http://purl.org/dc/terms/
  12: exif
  13: http://www.w3.org/2003/12/exif/ns#
  14: prf
  15: http://www.openmobilealliance.org/tech/profiles/UAPROF/ccppschema-2007511#

然后,我的Java代码(程序2):

AllegroGraphConnection agc = new AllegroGraphConnection();
 agc.enable();

 AllegroGraph ag = agc.open("test", AGPaths.TRIPLE_STORES);

 AGUtils.printStringArray("AG Namespaces (registed):", ag.getNamespaces());

运行,结果(程序2):

AG 命名空间(已注册):

 0: rdf
  1: http://www.w3.org/1999/02/22-rdf-syntax-ns#
  2: rdfs
  3: http://www.w3.org/2000/01/rdf-schema#
  4: owl
  5: http://www.w3.org/2002/07/owl#

在程序1中,我创建了一个名为“test”的AllegroGraph, 我注册了其他 5 个命名空间(foaf、dc、dct、exif、prf); 在程序2中,我打开创建的AllegroGraph,但是它的命名空间只有3个:rdf,rdfs,owl, 程序 1 中注册的其他 5 个命名空间丢失。

我的问题是:

  1. 为什么其他 5 个命名空间漏掉了?
  2. 如何在创建的 AllegroGraph 中保留 5 个已注册的命名空间? (当我打开创建的AllegroGraph时,我不需要再次注册命名空间。)
<小时/>

在我的程序中,注册所有 namespace 后,我添加了以下代码:

ag.closeTripleStore();

它没有用:(

最佳答案

简而言之,AllegroGraph 不会在三重存储中保留命名空间注册。命名空间是一种语法糖,它的存在是为了让长 URI 的读写变得更加容易。尽管有许多常用的缩写(rdf、owl、foaf、dc...),但每个人都可以自己编写并按自己认为合适的方式使用它们。如果 AllegroGraph 保留命名空间缩写,则商店将带有某人的个人缩写,如果其他人打开商店,这可能会导致困惑。

简而言之,如果您想使用命名空间,您应该设置代码以在启动时重新注册它们。另请注意,命名空间缩写对于正在运行的实例是全局的,而不是特定的三元组存储。

HTH

关于java - 在 AllegroGraph 中注册命名空间(缺少注册的命名空间。),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2190131/

相关文章:

python - 来自 AllegroGraph Python API 的 Prolog 查询中的 OWL 推理

java - 具有来自不同服务器的存储库的联合存储

java - 将列表更改为新列表后如何刷新 ListView?

java - 如何在 Smalltalk 中访问和使用 Java 库/包

java - Android - 当检查文本框长度是否大于或等于 1 并执行某些操作时,仅当字符长度为 3 或以上时才会执行

java - 如何称呼未实现列表的类似列表的对象

java - 如何避免在 Java 测试中重复插入

java - 有没有办法将 Java 服务器中的 GraphQL 查询转换为 SPARQL 查询?

Sparql - 排序依据最后返回空值

java - 使用java查找多个文本文件的共同元素的最佳方法是什么?