public class Main {
public static void main(String args[]){
//read an ontology
String filename = "IOTOntology.owl";
Model model = ModelFactory.createDefaultModel();
OntModel model1 = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
//over
// Waits for the device ID
System.out.print("Enter name of man: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String devID = null;
try {
devID = br.readLine();
} catch (IOException ioe) {
System.out.println("IO error trying to read device ID!");
System.exit(1);
}
try {
File file=new File(filename);
FileInputStream reader=new FileInputStream(file);
System.out.println("The absolute path of the file is:"+ file.getAbsolutePath());
model.read(reader, "RDF/XML");
// Create a SPARQL query from the given string.
String queryString = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "+
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "+
"PREFIX owl: <http://www.w3.org/2002/07/owl#>" +
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>" +
//"PREFIX act: <http://www.semanticweb.org/project/ontologies/2016/0/Actor#>" +
"select ?name "+
"where { "+
" ?User a rdf:name"+
"} \n ";
Query query = QueryFactory.create(queryString);
try (// Execute the query and obtain results
QueryExecution qe = QueryExecutionFactory.create(query, model)) {
ResultSet results = qe.execSelect();
// Output query results
ResultSetFormatter.out(System.out, results, query);
qe.close();
}
model.close();
} catch(Exception e) {
System.out.println(e.getMessage());
}
}
}
J'ai un problème parce que ma table est vide, il écrit dans la ligne de commande seulement ceci:Quelqu'un peut-il me dire comment lister tous les utilisateurs de l'ontologie dans eclipse?
--------
| name |
========
--------
et c'est le lien vers mon ontologie: https://github.com/isidoramalkata/IOTOntology.git