您使用的功能是 SPARQL 1.1,因此早期版本的 ARQ 不支持。编写接近您所做的查询的唯一方法是执行以下操作之一。
不同长度的联合路径
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT *
WHERE
{
{ ?x owl:sameAs ?y }
UNION
{ ?s owl:sameAs [ owl:sameAs ?y ] . }
UNION
{ ?s owl:sameAs [ owl:sameAs [ owl:sameAs ?y ] ] . }
# Repeat the above pattern up to whatever limit you want
}
使用客户端代码
发出如下初始查询:
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT * WHERE { ?x owl:sameAs ?y }
制作一个?y
值列表,然后为每个值发出如下形式的查询:
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT * WHERE { <constant> owl:sameAs ?y }
<constant>
每次替换列表中的一个值,然后将新值添加?y
到列表中。
使用这种方法唯一需要注意的是,您要跟踪已经发出第二个查询的值,以节省重复查询。