如何使用 SPARQL 获取数据类型属性值
我在 protege 中创建了一些样本本体。根据我的本体,有一个名为 person 的类,它的子类名为 Student。有一些学生个体(约翰,保罗,玛丽,...)。 我定义了一些名为“电子邮件”的数据属性并分配了他们的电子邮件地址。
以下查询导致本体中的所有个人。但我想获取每个人及其电子邮件地址。
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 ";
上面的查询在 eclipse IDE 中的 jena 上进行了测试。
任何想法..?
预先感谢!
I have created some sample ontology in protege.According to my ontology there is a class called person and which has sub class called Student.There are some student individuals(john,paul,marry,...).
I have defined some data property called "email" and assigned their email addresses.
Following query which is resulting all the individuals in ontology.But I want to get each individual and their email address.
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 ";
Above query was tested on jena in eclipse IDE.
any idea..?
Thank in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要获取电子邮件地址,您需要 1) 将它们的变量添加到 SELECT 行,2) 在 WHERE 模式中绑定该变量。您可能想为自己的本体添加前缀,因为您现在需要引用它两次。像这样的东西:
To get the email addresses you need to 1) add a variable for them to the SELECT line, and 2) bind that variable in the WHERE pattern. And you'll probably want to add a prefix for your own ontology, since you'll now need to refer to it twice. Something like:
更紧凑的方式如下:
A more compact way would be the following: