1

使用以下示例三元组:

@prefix : <http://www.me.org/me_schema#> .
@prefix dc: <http://purl.org/dc#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://www.me.org/content/me_schema>
  rdf:type owl:Ontology ;
  owl:imports <http://www.w3.org/2004/02/skos/core> ;
.
:a
  rdf:type owl:ObjectProperty ;
  rdfs:label "A" ;
  rdfs:subPropertyOf :b ;
.
:b
  rdf:type owl:ObjectProperty ;
  rdfs:label "B" ;
  rdfs:subPropertyOf :c ;
.
:c
  rdfs:label "C"^^xsd:string ;
.

此查询按预期返回两行(列 ?o 中的 b 和 c):

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

select * 
from <test>
where
{
  ?s rdfs:label 'A' .
  ?s rdfs:subPropertyOf+ ?o
}

但是,我希望以下内容返回 1 行,但它返回空结果。在查询控制台中测试:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

select * 
from <test>
where
{
  ?s rdfs:label 'A' .
  ?s rdfs:subPropertyOf+ <http://www.me.org/me_schema#c>
}

我希望它为“a”返回一行。这是一个错误还是我错过了一些明显的东西?

我尝试使用DBPedia进行类似的查询,它似乎返回了我预期的数据。例如,以下查询为“star”返回两行,尽管两者都不是直接的 subClassOf owl:Thing。

select *
where 
{
 ?s rdfs:label  "star"@en .
 ?s rdfs:subClassOf+ owl:Thing
} LIMIT 100

如果有人遇到同样的问题,我想出了以下解决方法:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

select * 
from <test>
where
{
  ?s rdfs:label 'A' .
  ?s rdfs:subPropertyOf ?s2 .
  ?s2 rdfs:subPropertyOf* <http://www.me.org/me_schema#c>
}
4

1 回答 1

7

(我会把它放在评论中,但我没有这样做所需的声誉。)

我刚刚在 MarkLogic 8.0-3 上尝试了你的空结果示例,我确实得到[{"s":"<http://www.me.org/me_schema#a>"}]了,正如你所期望的那样。您使用的是早期版本的 MarkLogic(您可以在左上角看到版本localhost:8001)?

为了验证这一点,我转到MarkLogic 查询控制台localhost:8000/qconsole/将“内容源”设置为我的数据库(打开三重索引),将查询类型更改为“SPARQL 更新”,并输入以下 SPARQL 插入代码:

PREFIX : <http://www.me.org/me_schema#>
prefix dc: <http://purl.org/dc#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>

INSERT DATA { GRAPH <test> {
  <http://www.me.org/content/me_schema>  rdf:type owl:Ontology .
  <http://www.me.org/content/me_schema> owl:imports <http://www.w3.org/2004/02/skos/core> .

 :a rdf:type owl:ObjectProperty .
 :a rdfs:label "A" .
 :a rdfs:subPropertyOf :b .

 :b rdf:type owl:ObjectProperty .
 :b rdfs:label "B" .
 :b rdfs:subPropertyOf :c .

 :c rdfs:label "C"^^xsd:string .

  }}

然后我在查询控制台中打开了一个新选项卡,将查询类型设置为“SPARQL 查询”,然后运行您的确切查询:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

select * 
from <test>
where
{
  ?s rdfs:label 'A' .
  ?s rdfs:subPropertyOf+ <http://www.me.org/me_schema#c>
}

如果您使用的是早期版本的 MarkLogic,请尝试在MarkLogic 下载页面上更新到最新版本。

于 2015-12-17T17:49:01.673 回答