开发者

Setup RDF ontology with Virtuoso

I've googled for last few hours searching for tutorials or guides about how to configure RDF store with virtuoso server (open source version).

I have RDF file which was created with Protégé software. How can I add this file to virtuoso 开发者_运维技巧server and configure an end point to be able to insert/update or querying data via Jena or other API of that kind.


The easiest way to do it might be as explain on point (16.8.3) of this documentation page HTTP PUT using Content-Type: application/rdf+xml. This mechanism basically runs a HTTP PUT sending your file to the triple store.

curl -T your_file.rdf entity_uri_to_store_file -u user:pass

Think of entity_uri_to_store_file as if was the table where you want to save that file.

So lets say that your file is ontology1.owl and you want to save it in the entity http://myorganisation.com/ontologies/ontology1 your command then would look like ...

curl -T ontology1.owl http://myorganisation.com/ontologies/ontology1 -u user:pass

Note: if you're running a Windows box you can install curl from here.

To query the data afterwards ... you can also do it with curl.

curl -F "query=YOUR SPARQL QUERY" http://your.virtuososerver.org/sparql

Notice that you have to use SPARQL to access the data.

In the case of Jena, you have to use Jena ARQ, by command line ...

java -cp ... arq.query --service 'hhttp://your.virtuososerver.org/sparql' 'SELECT * WHERE {?s ?p ?o}'

or programatically by using the API ...

import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.sparql.engine.http.QueryExceptionHTTP;

public class QueryTest {

public static void main(String[] args) {
    String service = "http://your.virtuososerver.org/sparql";
    String query = "SELECT * WHERE {?s ?p ?o}";
    QueryExecution qe = QueryExecutionFactory.sparqlService(service, query);
    try {
       ResultSet results = qe.execSelect() ;
       for ( ; results.hasNext() ; ) {
           QuerySolution soln = results.nextSolution() ;
           RDFNode x = soln.get("s") ;
           RDFNode r = soln.get("p") ; 
           RDFNode l = soln.get("o") ;   
       }
    } catch (Exception e) {
        System.out.println("Query error:"+e);
    } finally {
        qe.close();
    }
 }

Just remember to point the variable service to where your virtuoso server is listening.


From the Virtuoso Conductor (http:cname:8890/conductor) you can go to the "RDF -> RDF Store Upload" tab where you can upload RDF datasets file from file system or a URL location.

The Virtuoso Jena Provider can be used for querying the Virtuoso Quad Store using the Jena Franework.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜