English 中文(简体)
Registering Namespace in AllegroGraph (Registered nameSpaces is missing.)
原标题:

I have a problem about registering namespace in AllegroGraph.

My Java code (program 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());

Run, And the result(program 1):

AG Namespaces (initially):
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#

AG Namespaces (registered):

  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#

Then, my Java code (program 2):

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

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

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

Run, and the result(program 2):

AG Namespaces (registered):

 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#

In program 1, I create a AllegroGraph which name is "test", and I registered the other 5 namespaces(foaf, dc, dct, exif, prf); in program 2, I open the created AllegroGraph, but its namespace has only 3: rdf, rdfs, owl, the other 5 namespaces which is registered in program 1 is missing.

My question is:

  1. Why the other 5 namespaces missed?
  2. How can I keep the 5 registered namespaces in created AllegroGraph? (When I open the created AllegroGraph, I need not to register namespaces again.)

And in my program, after registered all the nameSpace, I added the following code:

ag.closeTripleStore();

and it is unuseful:(

问题回答

In short, AllegroGraph does not persist namespace registration in the triple-store. Namespaces are syntactic sugar that exist to make it easier to read and write long URIs. Even though there are many commonly used abbreviations (rdf, owl, foaf, dc, ...), each person can make up their own and use them as they see fit. If AllegroGraph persisted the namespace abbreviations, then the store would carry someone s personal abbreviations with it which could cause confusion if someone else opened the store.

In short, if you want to use namespaces, you should set up your code to re-register them on start up. Also, note that the namespace abbreviations are global to the running instance, not to a particular triple-store.

HTH





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签