[英]How can I reuse result from JQuery for javascript textual matching?
[英]How can I reuse the result of a SPARQL query to another query?
例如我有這個查詢
SELECT ?x
WHERE {?x :has_input "z"}
然后我想使用?x
的結果作為另一個查詢的對象
SELECT ?y
WHERE {?y :uses "x"}
有什么想法要實現嗎? 提前致謝
為了舉例說明,讓我們定義一些數據:
@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 .
基於此數據,並指定了任何特定的API(因為沒有指定),您就有了一些SPARQL級別的選項。 首先是簡單地組合查詢,在這種情況下這很容易:
prefix : <http://example.org/>
select ?y where {
?x :has_input "z" .
?y :uses ?x .
}
$ arq --data data.n3 --query combined-query.sparql
----------
| y |
==========
| :node3 |
----------
另一種選擇是使用子查詢
prefix : <http://example.org/>
select ?y where {
{
select ?x where {
?x :has_input "z" .
}
}
?y :uses ?x .
}
$ arq --data data.n3 --query subquery.sparql
----------
| y |
==========
| :node3 |
----------
第三種可能是您實際需要的,如果您必須分別執行查詢,則是執行一個查詢,該查詢為您找到?x
值,然后執行一個查詢,找到?y
,但帶有?x
值嵌入values
。 第一個查詢如下所示,並返回:
prefix : <http://example.org/>
select ?x where {
?x :has_input "z" .
}
$ arq --data data.n3 --query xquery.sparql
----------
| x |
==========
| :node2 |
| :node0 |
----------
然后,基於這些值,為?y
創建查詢:
prefix : <http://example.org/>
select ?y where {
values ?x { :node2 :node0 }
?y :uses ?x .
}
$ arq --data data.n3 --query yquery.sparql
----------
| y |
==========
| :node3 |
----------
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.