无法使用SPARQL来预定义层次结构 [英] Can't PREFIX hierarchies with SPARQL

查看:91
本文介绍了无法使用SPARQL来预定义层次结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要像这样在我的URL中表示一个层次结构:

I have a need to represent a hierarchy in my URL's like this:


http://www.me.org/
-----------------root1/
-----------------------level1/
------------------------------level2/etc

我想定义PREFIX,并在SPARQL查询中使用它们,如下所示:

I want to define PREFIX's and used them in a SPARQL query like this:


PREFIX root1: <http://www.me.org/root1/>

select * where {
    ?s ?p root1:level1/level2/etc .
} limit 100

这将在ARQ中失败,并显示以下错误:

This will fail in ARQ with the following error:


Encountered " "/" "/ "" at line 10, column 43.
Was expecting one of:
    "values" ...
    "graph" ...
...

我应该这样在我的URL中表示一个层次结构,还是SPARQL和PREFIX的使用仅限于一个级别?

Should I be able to represent a hierarchy in my URL's like this or is SPARQL and PREFIX use limited to a single level ?

推荐答案

您可以在前缀声明中使用相对URI:

You can use relative URIs in prefix declarations:

BASE <http://example/>
PREFIX root1:  <root1/>
PREFIX level1: <root1/level1/>
PREFIX level2: <root1/level1/level2/>

SELECT * {
  ?s ?p  level2:etc .
}

避免了在URI中重复部分字符串的一些开销.

which avoids some of the overhead of repeating part-strings in URIs.

这篇关于无法使用SPARQL来预定义层次结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆