0

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

我的问题是:

  1. 为什么其他 5 个命名空间错过了?
  2. 如何将 5 个已注册的命名空间保留在 created 中AllegroGraph?(当我打开 createdAllegroGraph时,我不需要再次注册命名空间。)

在我的程序中,注册完所有的命名空间后,我添加了以下代码:

ag.closeTripleStore();

它是无用的:(

4

1 回答 1

1

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

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

高温高压

于 2010-09-13T13:34:55.220 回答