简体   繁体   English

使用自动分配的空白节点和具体数据

[英]Use automatically-assigned blank node with reified data

I'm trying to query a dataset which uses the RDF reification vocabulary, something like this:我正在尝试查询使用 RDF 物化词汇的数据集,如下所示:

myprefix:statement1 rdf:subject myprefix:object1 .
myprefix:statement1 rdf:predicate myprefix:isrelatedto .
myprefix:statement1 rdf:object myprefix:object2 .

myprefix:statement2 rdf:subject myprefix:object2 .
myprefix:statement2 rdf:predicate myprefix:isrelatedto .
myprefix:statement2 rdf:object myprefix:object3 .

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix myprefix: <mydomain#>
select *
from <mydomain>
where {
 [ rdf:subject ?first ; rdf:predicate myprefix:isrelatedto ; rdf:object _:1 ] .
 [ rdf:subject _:1 ; rdf:predicate myprefix:isrelatedto ; rdf:object ?second ] .
}

Result:
 __________________ __________________
| first            | second           |
|__________________|__________________|
| myprefix:object1 | myprefix:object2 |
|__________________|__________________|

Can I replace the labelled blank node _:1 with the [ ] construction somehow?我可以用 [ ] 构造以某种方式替换标记的空白节点 _:1 吗?

EDIT: Should explain that the reason for the question was that in the real use case I have a much more complex query that needs to get a variable number of properties like this (the query is generated dynamically).编辑:应该解释问题的原因是,在实际用例中,我有一个更复杂的查询,需要获取可变数量的这样的属性(查询是动态生成的)。 So what I'm trying to do is get rid of the labelled node so that I don't have to generate unique labels dynamically.所以我想要做的是摆脱带标签的节点,这样我就不必动态生成唯一的标签。

[ ] works when there is at most one reference to it. [ ]在最多有一个引用时有效。

Here we have:在这里,我们有:

... rdf:object _:1

... rdf:subject _:1

so two references to the blank node as currently written.所以两个对当前写入的空白节点的引用。

If you can modify the rest of the query, it may be possible.如果可以修改查询的rest,可能是可以的。 Whether the intent is clearer is something you'll have to make a judgement on.意图是否更清晰是您必须做出判断的事情。

Because in the part:因为在部分:

[ rdf:subject _:1 ; ....]

isn't using the outer [ ] blank node for anything so it might be possible to have rdf:object/^rdf:subject as suggested in the comment.没有将外部[ ]空白节点用于任何内容,因此可能有评论中建议的rdf:object/^rdf:subject

Whether the intent is clearer is something you'll have to make a judgement on.意图是否更清晰是您必须做出判断的事情。

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

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