我在protege中创建了一些样本本体.根据我的本体论,有一个叫做person的类,它有一个名为Student的子类.有一些学生个体(john,paul,marry,......).我已经定义了一些名为"email"的数据属性并分配了他们的电子邮件地址.
以下查询导致本体中的所有个体.但我想获得每个人及其电子邮件地址.
String queryStr =
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "+
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "+
"select ?ind "+
"where { "+
"?ind rdf:type <http://www.semanticweb.org/ontologies/2010/5/Ontology1275975684120.owl#Student> ;"+
"}\n ";
Run Code Online (Sandbox Code Playgroud)
以上查询在eclipse IDE中的jena上进行了测试.
任何的想法..?
预先感谢!
要获取您需要的电子邮件地址1)为SELECT行添加一个变量,2)在WHERE模式中绑定该变量.而且你可能想为你自己的本体添加一个前缀,因为你现在需要两次引用它.就像是:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX my: <http://www.semanticweb.org/ontologies/2010/5/Ontology1275975684120.owl#>
SELECT ?ind ?email
WHERE {
?ind rdf:type my:Student .
?ind my:Email ?email
}
Run Code Online (Sandbox Code Playgroud)