stored-procedures - 如何遍历引用虚拟图的 SPARQL 查询?

标签 stored-procedures iteration sparql virtuoso r2rml

我正在开发 Virtuoso 存储过程。
我想对 SPARQL 查询的结果执行循环到图形。
当查询包含对虚拟图(实际上不在三元组中的图,是 R2RML 映射操作的结果)的引用时,问题就出现了。在我所有的尝试中,我没有得到任何错误,但也得到了一个空的结果集。
我尝试了以下

create procedure R2RML.DBA.try() returns integer
{
  for (sparql define input:storage ""
       select ?s ?p
       from <http://example.com/resource>
       where {
         ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o .
       }  LIMIT 5 ) do
    {
      use_the_value("s");
    }
};

还有以下
create procedure R2RML.DBA.try() returns integer
{
  declare srcgraph varchar;
  srcgraph := 'http://ec.example.com/resource';
  for (sparql define input:storage ""
        select ?s ?p
        where {
        GRAPH `iri(?:srcgraph)` 
          {
            ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o .
          }
        }  LIMIT 5 ) do
    {
      use_the_value("s");
    }
};

在这两种情况下,尽管查询相同,但在 SPARQL 端点中执行时,不会执行迭代,返回结果。

如果我删除对图形的引用,则执行迭代:
create procedure R2RML.DBA.try() returns integer
{
  for (sparql define input:storage ""
        select ?s ?p
        where {
          ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o .
        }  LIMIT 5 ) do
    {
      use_the_value("s");
    }
};

有人知道我做错了什么吗?

最佳答案

由于图形是虚拟的,所以诀窍是在 define 中添加四元存储的名称。 SPARQL 语句中的指令。例如,如果使用 Virtuoso 四边形 map 存储 define指令将变为以下内容。

sparql define input:storage "http://www.openlinksw.com/schemas/virtrdf#DefaultQuadStorage"

关于stored-procedures - 如何遍历引用虚拟图的 SPARQL 查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42434965/

相关文章:

mysql - 动态 SQL 替代方案 (MySql)

python - 对数组中每个元素直到当前元素进行条件迭代

java - 循环中的 ConcurrentModificationException

Python Sparql 查询本地文件

sql-server - 退出存储过程

mysql - 在 where 子句中使用函数

python - 如何停止将元素放入列表中

rdf - 确定 DBpedia 资源是城市还是国家

sparql - RDFox:本地IRI ':born_in'中的前缀名称尚未绑定(bind)

entity-framework - 在Code First 4.1中执行存储过程