I'm trying to query a dataset which uses the RDF reification vocabulary, something like this:
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?
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.