I am trying to CONSTRUCT complete RDF Collections with a SPARQL 1.1 property path. The property path examples that I have seen are able to get the rdf:first nodes, but I have yet to see one that is able to get the whole chain, including the bnodes. The key parts of the query look like this:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX sc: <http://iiif.io/api/presentation/2#>
CONSTRUCT {?range sc:hasCanvases ?listid .
?listid rdf:first ?canvas .
?listid rdf:rest ?mid .
?mid rdf:rest ?node .
?node rdf:first ?canvas .
?node rdf:rest ?last .
[...]}
WHERE {values ?range {<http://some.uri>}
?range sc:hasCanvases ?listid .
values ?e { rdf:first rdf:rest }
?listid rdf:rest* ?mid .
?mid ?e ?node FILTER (?mid != ?node).
?listid rdf:first ?first .
?node rdf:first ?canvas .
?node rdf:rest ?last .
[...]}
It mostly works, except that the ?listid node binds to every rdf:rest ?mid object in the property path.
There is a referencedOnce constraint in the jsonld.fromRDF method that makes these extra head triples problematic for list reconstruction with that library. I have tried a variety of subqueries, property paths and FILTERS, but am quite stuck on this. Is it possible?
?headin the query... - Joshua Taylor?range sc:hasCanvases ?listid .?listid rdf:first ?canvas .?listid rdf:rest ?mid .to this:?range sc:hasCanvases ?listid .?mid rdf:first ?canvas .?mid rdf:rest ?last .and it works. It seems that the subject of the property path is iteratively bound to every matching object in the path. So when referenced in CONSTRUCT, it shows a pattern like 1-1, 1-2, 1-3, 1-4, 1-5. - Christopher Johnson