Dear Jena developers!
I have a somewhat simple example, but I cant see why it doesnt work.
The code is running, but I get no results.
It would be nice if you could help me out, thank you!!!
OntModel model = ModelFactory.createOntologyModel();
try {
InputStream in;
in = new FileInputStream("lib.owl");
String lib =
"http://www.semanticweb.org/ontologies/2010/10/library.owl#";
model.read(in, null);
String prolog = "PREFIX lib: <" + lib + ">";
String queryString = prolog + NL
+ "SELECT ?y WHERE {?x lib:speaks ?y}";
Query query = QueryFactory.create(queryString);
QueryExecution qexec =
QueryExecutionFactory.create(query, model);
ResultSet rs = qexec.execSelect();
while (rs.hasNext()) {
QuerySolution rb1 = rs.nextSolution();
// Get title - variable names do not include
the '?' (or '$')
RDFNode x1 = rb1.get("y");
print("x: " + x1);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY dc "http://purl.org/dc/elements/1.1/" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY owl2xml "http://www.w3.org/2006/12/owl2-xml#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY library
"http://www.semanticweb.org/ontologies/2010/10/library.owl#" >
]>
<rdf:RDF xmlns="http://www.semanticweb.org/ontologies/2010/10/library.owl#"
xml:base="http://www.semanticweb.org/ontologies/2010/10/library.owl"
xmlns:owl2xml="http://www.w3.org/2006/12/owl2-xml#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:library="http://www.semanticweb.org/ontologies/2010/10/library.owl#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#">
<owl:ObjectProperty rdf:about="#speaks">
<rdfs:domain rdf:resource="#Author"/>
<rdfs:range rdf:resource="#Language"/>
</owl:ObjectProperty>
<owl:Class rdf:about="#Author">
<rdfs:subClassOf rdf:resource="#DomainConcept"/>
</owl:Class>
<owl:Class rdf:about="#DomainConcept"/>
<owl:Class rdf:about="#English">
<rdfs:subClassOf rdf:resource="#Language"/>
</owl:Class>
<owl:Class rdf:about="#German">
<rdfs:subClassOf rdf:resource="#Language"/>
</owl:Class>
<owl:Class rdf:about="#Language">
<rdfs:subClassOf rdf:resource="#DomainConcept"/>
</owl:Class>
<owl:Class rdf:about="#S.Meyer">
<rdfs:subClassOf>
<owl:Class>
<owl:intersectionOf rdf:parseType="Collection">
<rdf:Description rdf:about="#Author"/>
<owl:Restriction>
<owl:onProperty rdf:resource="#speaks"/>
<owl:someValuesFrom>
<owl:Class>
<owl:intersectionOf rdf:parseType="Collection">
<rdf:Description rdf:about="#English"/>
<rdf:Description rdf:about="#German"/>
</owl:intersectionOf>
</owl:Class>
</owl:someValuesFrom>
</owl:Restriction>
</owl:intersectionOf>
</owl:Class>
</rdfs:subClassOf>
<rdfs:comment
>quantifier restriction defined</rdfs:comment>
</owl:Class>
<owl:Class rdf:about="#T.Canavan">
<rdfs:subClassOf>
<owl:Class>
<owl:intersectionOf rdf:parseType="Collection">
<rdf:Description rdf:about="#Author"/>
<owl:Restriction>
<owl:onProperty rdf:resource="#speaks"/>
<owl:someValuesFrom rdf:resource="#English"/>
</owl:Restriction>
</owl:intersectionOf>
</owl:Class>
</rdfs:subClassOf>
<rdfs:comment
>quantifier restriction defined</rdfs:comment>
</owl:Class>
</rdf:RDF>