首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenRDF Sesame:无法定义前缀

OpenRDF Sesame:无法定义前缀
EN

Stack Overflow用户
提问于 2012-03-16 02:24:52
回答 1查看 2.4K关注 0票数 2

我试图为我的测试服务器构建正确的查询,但我面临着无法定义前缀的问题。

例如,下面的查询是这样的:

代码语言:javascript
复制
select * where
{
   ?stayingURL <http://localhost/resource_lng> ?lng .
   ?stayingURL <http://localhost/resource_staying_date> ?date .
   ?stayingURL <http://localhost/resource_address> ?address .
}
LIMIT 100

我尝试按日期添加过滤器,就像这样:

代码语言:javascript
复制
select * where
{
   ?stayingURL <http://localhost/resource_lng> ?lng .
   ?stayingURL <http://localhost/resource_staying_date> ?date .
   ?stayingURL <http://localhost/resource_address> ?address .
   FILTER (?date > "2012-01-01"^^xsd:date)
}
LIMIT 100

现在我得到了以下错误:"MALFORMED QUERY: org.openrdf.query.parser.sparql.ast.VisitorException: QName 'xsd:date' uses an undefined prefix

好的,我尝试通过在查询的开头添加以下行来手动声明这个前缀:

代码语言:javascript
复制
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

现在我得到了这个错误:

代码语言:javascript
复制
MALFORMED QUERY: Encountered " "<" "< "" at line 1, column 14.
 Was expecting:
 <Q_IRI_REF> ...

这对我来说很奇怪,但不管怎样,我试着直接写它,没有任何前缀:

代码语言:javascript
复制
select * where
{
 ?stayingURL <http://localhost/resource_lng> ?lng .
 ?stayingURL <http://localhost/resource_staying_date> ?date .
 ?stayingURL <http://localhost/resource_address> ?address .
 FILTER (?date > "2012-01-01"^^<http://www.w3.org/2001/XMLSchema#date> )
 }
LIMIT 100

结果几乎相同:

代码语言:javascript
复制
MALFORMED QUERY: Encountered " "<" "< "" at line 1, column 228.
Was expecting one of:
    <Q_IRI_REF> ...
    <PNAME_NS> ...
    <PNAME_LN> ...

我做错了什么?

这是我的服务器地址:http://176.34.226.101:8080/openrdf-sesame/repositories/ecomobile

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-16 05:05:48

如果我对所有的query参数进行URI编码,那么它对我来说是有效的:

代码语言:javascript
复制
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
select * where
{
 ?stayingURL <http://localhost/resource_lng> ?lng .
 ?stayingURL <http://localhost/resource_staying_date> ?date .
 ?stayingURL <http://localhost/resource_address> ?address .
 FILTER (?date > "2012-01-01"^^<http://www.w3.org/2001/XMLSchema#date> )
 }
LIMIT 100

这将是请求:

http://176.34.226.101:8080/openrdf-sesame/repositories/ecomobile?query=PREFIX%20xsd%3A%20%3Chttp%3A//www.w3.org/2001/XMLSchema%23%3E%20select%20%2A%20where%0A%7B%0A%20%20%20%3FstayingURL%20%3Chttp%3A//localhost/resource_lng%3E%20%3Flng%20.%0A%20%20%20%3FstayingURL%20%3Chttp%3A//localhost/resource_staying_date%3E%20%3Fdate%20.%0A%20%20%20%3FstayingURL%20%3Chttp%3A//localhost/resource_address%3E%20%3Faddress%20.%0A%20%20%20FILTER%20%28%3Fdate%20%3E%20%222012-01-01%22%5E%5Exsd%3Adate%29%0A%7D%0ALIMIT%20100

对于神秘的不可读的URI,很抱歉...这里有一个简短的版本:

http://bit.ly/xTQhSV

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9725828

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档