简短的回答是,数据看起来不像你的查询所期望的那样。让我们来看看这个RDF/XML片断描述图表:
<rdf:RDF xml:base="http://example.org/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:service="http://www.daml.org/services/owl-s/1.1/Service.owl#"
xmlns:profile="http://www.daml.org/services/owl-s/1.1/Profile.owl#">
<profile:Profile rdf:ID="AddServiceName">
<service:presentedBy rdf:resource="AddServicePresenter"/>
<profile:serviceName>"ser"</profile:serviceName>
</profile:Profile>
</rdf:RDF>
在龟格式
,这是更接近SPARQL的模式语言:
@prefix service: <http://www.daml.org/services/owl-s/1.1/Service.owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix profile: <http://www.daml.org/services/owl-s/1.1/Profile.owl#> .
<http://example.org/#AddServiceName>
a profile:Profile ;
profile:serviceName "\"ser\"" ;
service:presentedBy <http://example.org/AddServicePresenter> .
尤其要注意的是,在一个元素与RDF图中的主题或对象相对应的RDF/XML可以使用其XML元素名称作为rdf:type
语句的简写。所以<profile:Profile rdf:ID="x">…</profile:Profile>
说资源<...#x>
有rdf:type profile:Profile
。在Turtle和SPARQL中,a
是rdf:type
的简写,所以<...#x> a profile:Profile
表示<...#x> rdf:type profile:Profile
。 <...#x>
的其他属性由元素的内容决定。在这种情况下,<...#AddServiceName>
有两个属性,一个用于service:presentedBy
,另一个用于profile:serviceName
。
要查找资料,他们的主持人,和名称,你需要这样的查询:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX service: <http://www.daml.org/services/owl-s/1.1/Service.owl#>
PREFIX profile: <http://www.daml.org/services/owl-s/1.1/Profile.owl#>
SELECT ?profile ?presenter ?name WHERE {
?profile a profile:Profile ;
service:presentedBy ?presenter ;
profile:serviceName ?name .
}
三重模式也可以在一个更详细的形式写成:
?profile rdf:type profile:Profile .
?profile service:presentedBy ?presenter .
?profile profile:serviceName ?name .
运行此查询产生这些结果:
$ arq --query query.sparql --data data.rdf
-----------------------------------------------------------------------------------------------
| profile | presenter | name |
===============================================================================================
| <http://example.org/#AddServiceName> | <http://example.org/AddServicePresenter> | "\"ser\"" |
-----------------------------------------------------------------------------------------------
非常感谢你,但是它的语法有问题,它可能与th e版本的SPARQL或Jena或者两者都可以,查询不起作用。 –
甚至“profile:servicename”也不起作用,所以我不得不编写整个URI,而且它很安静。 –
@AousDeeb URI区分大小写,所以'profile:serviceName'是与'profile:servicename'不同的URI。 –