0

In Jena, I saved RDF/XML documents in SDB using the "read()" method and even created a file with RDF/XML documents in SDB using the "write" method. What I want to try is to save Triple directly in SDB.

Here is my code

prefix = "http://example.org/terms/";
ns = "ex";
model.setNsPrefix(ns, prefix);
prefix3 = "http://www.w3.org/1999/02/22-rdf-syntax-ns";
ns3 = "rdf";
model.setNsPrefix(ns3, prefix3);
prefix6 = "http://www.test/2022/#";
ns6 = "base";
model.setNsPrefix(ns6, prefix6);
            for(i = 0; i<index; i++) {
            Resource s_A = model.createResource(A[i].o);        
            Property p_A = model.createProperty(prefix3);                       
            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);        
            
            //model.add(s_A, p_A, prefix6); //wish <ex:Description rdf:about=baseURI+"ID">
            model.add(s_A, p_B, B[i].o);    //wish <ex:Description.type>1</ex:Description.type>
            model.add(s_A, p_C, C[i].o);    //wish <ex:Description.open>0</ex:Description.open>
                                            //wish </ex:Description>
            }

I know this(model.add(s_A, p_A, prefix6);) part is wrong, but I don't know which method I use to wish. I don't know what else to do here.

user20297975
  • 129
  • 8
  • FYI Jena SDB has been end of life since Dec 2020 and the Apache Jena project recommends using alternatives such as Jena TDB 2 - https://jena.apache.org/documentation/tdb2/index.html – RobV Nov 14 '22 at 13:32
  • You haven't provided a complete example code here or clearly stated what you actually want to do. You seem to be conflating the RDF abstract data model i.e. triples with the RDF/XML serialisation. If you want to create triples then you just need to be concerned with the triples and not how they will eventually be serialised to a file e.g. `ex:Rob rdf:type ex:Person` – RobV Nov 14 '22 at 13:53

0 Answers0