tags:

views:

35

answers:

2

Hi, every one. I have a problem about registing 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: h t t p://www.w3.org/1999/02/22-rdf-syntax-ns# 2: rdfs 3: h t t p://www.w3.org/2000/01/rdf-schema# 4: owl 5: h t t p://www.w3.org/2002/07/owl#

AG Namespaces (registed): 0: rdf 1: h t t p://www.w3.org/1999/02/22-rdf-syntax-ns# 2: rdfs 3: h t t p://www.w3.org/2000/01/rdf-schema# 4: owl 5: h t t p://www.w3.org/2002/07/owl# 6: foaf 7: h t t p://xmlns.com/foaf/0.1/ 8: dc 9: h t t p://purl.org/dc/elements/1.1/ 10: dct 11: h t t p://purl.org/dc/terms/ 12: exif 13: h t t p://www.w3.org/2003/12/exif/ns# 14: prf 15: h t t p://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 (registed): 0: rdf 1: h t t p://www.w3.org/1999/02/22-rdf-syntax-ns# 2: rdfs 3: h t t p://www.w3.org/2000/01/rdf-schema# 4: owl 5: h t t p://www.w3.org/2002/07/owl#

In program 1, I create a AllegroGraph which name is "test", and I registed 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 registed in program 1 is missing.

My question is: 1. Why the other 5 nameSpaces missed? 2. How can I keep the 5 registed nameSpaces in created AllegroGraph? (When I open the created AllegroGraph, I need not to regist nameSpaces again.)

Thank you very much, every one:)

A: 

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

ag.closeTripleStore();

and it it unuseful:(

WellBeing
A: 

Hi there. 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