Hi @r_moquin, thanks for your comment
While it sounds like a good idea a priori, it's not as easy as it looks. The namespace prefixes are local to a document (or to a serialisation to be more precise). Their only purpose is to make it more readable to humans (actually not all serialisations allow the definition of namespace prefixes!)
All this to say that when we parse an RDF document, all we read are triples where all resources are expanded as full uris and prefix definitions are lost. Let me give you an example.
I can carefully write this document using Turtle as serialisation format:
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix skosxl: <http://www.w3.org/2008/05/skos-xl#> .
<https://myvoc.com/aConcept>
a skos:Concept ;
skos:broader <https://myvoc.com/aBroaderConcept> ;
skosxl:prefLabel <https://myvoc.com/aConcept_prefLabel_es> .
<https://myvoc.com/aConcept_prefLabel_es>
a skosxl:Label ;
skosxl:literalForm "un concepto"@es .
But when parsed, it becomes a set of triples formed of uris and literals (no trace of prefixes):
<https://myvoc.com/aConcept> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2004/02/skos/core#Concept> .
<https://myvoc.com/aConcept> <http://www.w3.org/2004/02/skos/core#broader> <https://myvoc.com/aBroaderConcept> .
<https://myvoc.com/aConcept> <http://www.w3.org/2008/05/skos-xl#prefLabel> <https://myvoc.com/aConcept_prefLabel_es> .
<https://myvoc.com/aConcept_prefLabel_es> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
<https://myvoc.com/aConcept_prefLabel_es> <http://www.w3.org/2008/05/skos-xl#literalForm> "un concepto"@es .
Now, after the explanation, I have to say that I agree with you, that when using the shortened notation for URIs in Neo4j (skos__broader
,skosxl__prefLabel
,myvoc__Category1
,...), it is very useful to be able to keep the namespaces prefixes that we're used to. That is why we added two methods that can be of help:
With n10s.nsprefixes.add
you can define prefix-namespace pairs beforehand so when you import RDF using these namespaces, the predefined prefix will be used instead of having a sequential one generated dynamically by neosemantics.
call n10s.nsprefixes.add("skosxl","http://www.w3.org/2008/05/skos-xl#")
The problem with that is they have to be added one by one which can be tedious. Sometimes what we want to do is just grab all the definitions in our RDF document and have them added at once.
You can use for this the n10s.nsprefixes.addFromText
procedure. And pass as parameter just a piece of text from your RDF document header. It does not matter if it is the header section of a Turtle, RDF/XML or JSON-LD document, the addFromText
method will try its best to extract the prefix definitions in it and add them to the set defined in Neo4j so they are used when you import your RDF.
call n10s.nsprefixes.addFromText('
@prefix neo4voc: <http://neo4j.org/vocab/sw#> .
@prefix neo4ind: <http://neo4j.org/ind#> .
@prefix skosxl: <http://www.w3.org/2008/05/skos-xl#> .
')
Well, long explanation but I hope it will help you as well as other users in your situation.
Let me know your thoughts and please share your experience with neosemantics. It will help us make it better.
Cheers,
JB.