我在 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 个命名空间丢失了。
我的问题是:
- 为什么其他 5 个命名空间错过了?
- 如何将 5 个已注册的命名空间保留在 created 中
AllegroGraph?(当我打开 createdAllegroGraph时,我不需要再次注册命名空间。)
在我的程序中,注册完所有的命名空间后,我添加了以下代码:
ag.closeTripleStore();
它是无用的:(