Search code examples
jenatriplestoreprefixes

How to mapping prefixes to nodes in Jena SDB


After numerous attempts, I entered triple and prefixes data into SDB through add (Resource, Property, String) and setNsPrefix (ns, prefix). However, only hash, lex, and type for triple are stored in nods. Is it possible to mapping the information of prefixes to the hash, lex, and type of nodes?

`

model.setNsPrefix(ns, prefix);
model.setNsPrefix(ns2, prefix2);
model.setNsPrefix(ns3, prefix3);
model.setNsPrefix(ns3, prefix3);

for(i = 0; i<index; i++) {
            Resource s_A = model.createResource(A[i].s);
            Property p_A = model.createProperty(A[i].p);
            
            Resource s_B = model.createResource(B[i].s);
            Property p_B = model.createProperty(B[i].p);
            
            Resource s_C = model.createResource(C[i].s);
            Property p_C = model.createProperty(C[i].p);
            
            Resource s_D = model.createResource(D[i].s);
            Property p_D = model.createProperty(D[i].p);
            
            Resource s_E = model.createResource(E[i].s);
            Property p_E = model.createProperty(E[i].p);
            
            model.add(s_A, p_A, A[i].o);
            model.add(s_B, p_B, B[i].o);
            model.add(s_C, p_C, C[i].o);
            model.add(s_D, p_D, D[i].o);
            model.add(s_E, p_E, E[i].o);
            }

`


Solution

  • Prefix are stored in a separate table.

    As a general point, prefixes have no part in the RDF data model. They only exist to assist formatting output. there is no mapping from prefix to terms using the URI of the prefix name. That is all sorted out on parsing input.

    Use on output is determined by the RDF writer outputting RDF; nothing to do with SDB which just stores the prefixes.

    See class PrefixMappingSDB.