Jena
has the read
method that helps loading an ontology from file in the model. Is there something similar for virtuoso using the Jena API
?
That will greatly helps me test virtuoso on my already existing ontology store in n-triple format.
If you want to read an ontology from a Virtuoso server, you will need the "JDBC"-like drivers for Virtuoso, as explained here: http://virtuoso.openlinksw.com/dataspace/doc/dav/wiki/Main/VirtJenaProvider The download is at http://virtuoso.openlinksw.com/dataspace/doc/dav/wiki/Main/VOSDownload#Jena%20Provider though I preferred to compile it from source -
then you can do something like:
VirtDataset dataSet = new VirtDataset("jdbc:virtuoso://localhost:1111/charset=UTF-8/","user","pass");
Model baseModel = dataSet.getNamedModel("http://my.graph.name/");
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, baseModel);
This should allow access to all your RDF-Triples stored in Virtuoso (one graph at a time). If you just want the RDF, leave out the last line with the "OntModel" construction. Same if the store is very large, as it loads the complete ontology into RAM.
The Jena read
method may be used also with Virtuoso Jena provider. Like the next:
try {
String nfile = "1.nt";
Model model = VirtModel.openDatabaseModel("load:test", "jdbc:virtuoso://localhost:1111", "dba", "dba");
InputStream in = FileManager.get().open( nfile );
if (in == null) {
throw new IllegalArgumentException( "File: " + nfile + " not found");
}
model.read(new InputStreamReader(in), null, "N-TRIPLE");
model.close();
} catch (Exception e) {
System.out.println("Ex="+e);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.