繁体   English   中英

如何使用sparql查询从示例owl数据中获取数据

[英]How do get data from example owl data using sparql query

这是我的例子猫头鹰:

    <rdf:type rdf:resource="http://www.w3.org/2000/10/swap/pim/contact#Person"/>
    <foaf:age rdf:datatype="http://www.w3.org/2001/XMLSchema#string">10</foaf:age>
    <foaf:birthday rdf:datatype="http://www.w3.org/2001/XMLSchema#string">10.10</foaf:birthday>
    <foaf:firstName rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Liis</foaf:firstName>
</owl:NamedIndividual>

因为im rookie with sparql,我想知道怎么做一个查询来获取这个rdf的所有实例<rdf:type rdf:resource="http://www.w3.org/2000/10/swap/pim/contact#Person"/>

nd然后从它获取数据例如get age和get age = 10或获取name和name =“someName” <foaf:age rdf:datatype="http://www.w3.org/2001/XMLSchema#string">10</foaf:age>我的意思是从这一行获取数据。

我对这个问题的回答是:这个查询帮助你找到所有实例,s是对象名,p是这个数据的类型,o是行的值。

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX resource: <http://purl.org/vocab/resourcelist/schema#>

select distinct ?s ?p ?o ?k where {
?s ?p ?o ;
  a <http://www.w3.org/2000/10/swap/pim/contact#Person> .
?k foaf:age ?x .}

第二部分?k foaf:age ?x . 是如何通过类型名称来实例化实例数据。 结果是<http://example.register.nl/nationaalhandelsregister#person1>,10

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM