for example have query
select ?x {?x :has_input "z"} then want use result/s of ?x object query
select ?y {?y :uses "x"} any ideas how achieve that? in advance
for sake of example, let's define data:
@prefix : <http://example.org/> . :node0 :has_input "w", "z" . :node1 :has_input "x", "y" . :node2 :has_input "y", "z" . :node3 :uses :node2 . :node4 :uses :node1 . based on data, , specifying particular api (because didn't), you've got few sparql level options. first combining queries, easy enough in case:
prefix : <http://example.org/> select ?y { ?x :has_input "z" . ?y :uses ?x . } $ arq --data data.n3 --query combined-query.sparql ---------- | y | ========== | :node3 | ---------- another option use subquery
prefix : <http://example.org/> select ?y { { select ?x { ?x :has_input "z" . } } ?y :uses ?x . } $ arq --data data.n3 --query subquery.sparql ---------- | y | ========== | :node3 | ---------- a third, may need, if have execute queries separately, execute query finds values ?x you, , execute query finds ?y, ?x values embedded values. first query looks , returns:
prefix : <http://example.org/> select ?x { ?x :has_input "z" . } $ arq --data data.n3 --query xquery.sparql ---------- | x | ========== | :node2 | | :node0 | ---------- then, based on values, create query ?y:
prefix : <http://example.org/> select ?y { values ?x { :node2 :node0 } ?y :uses ?x . } $ arq --data data.n3 --query yquery.sparql ---------- | y | ========== | :node3 | ----------
Comments
Post a Comment