sparql期望"where","using"之一. [英] sparql expecting one of "where", "using"

查看:156
本文介绍了sparql期望"where","using"之一.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Fuseki服务器的Web界面中执行简单的插入查询.我已将端点设置为/update(而不是默认的/sparql). 我从 https://www.w3.org/Submission/SPARQL-Update/获取以下查询:

I am trying to do a simple insert query in the web interface of Fuseki server. I have set the endpoint to /update (instead of the default /sparql). I have the following query from https://www.w3.org/Submission/SPARQL-Update/:

PREFIX dc: <http://purl.org/dc/elements/1.1/>
INSERT { <http://example/egbook3> dc:title  "This is an example title" }

此查询被翻译为: http://localhost:3033/dataset.html#query=PREFIX+dc%3A+%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%3E%0AINSERT+%7B+%3Chttp%3A%2F%2Fexample%2Fegbook3%3E+dc%3Atitle++%22This+is+an+example+title%22+%7D%0A 或者 使用Share your query按钮可以看到curl http://localhost:3033/infUpdate/update -X POST --data 'update=PREFIX+dc%3A+%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%3E%0AINSERT+%7B+%3Chttp%3A%2F%2Fexample%2Fegbook3%3E+dc%3Atitle++%22This+is+an+example+title%22+%7D%0A' -H 'Accept: text/plain,*/*;q=0.9'.

This query gets translated to: http://localhost:3033/dataset.html#query=PREFIX+dc%3A+%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%3E%0AINSERT+%7B+%3Chttp%3A%2F%2Fexample%2Fegbook3%3E+dc%3Atitle++%22This+is+an+example+title%22+%7D%0A or curl http://localhost:3033/infUpdate/update -X POST --data 'update=PREFIX+dc%3A+%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%3E%0AINSERT+%7B+%3Chttp%3A%2F%2Fexample%2Fegbook3%3E+dc%3Atitle++%22This+is+an+example+title%22+%7D%0A' -H 'Accept: text/plain,*/*;q=0.9' as visible using the Share your query button.

查询返回以下错误:

Error 400: Encountered "<EOF>" at line 2, column 73.
Was expecting one of:
    "where" ...
    "using" ...



Fuseki - version 2.4.0 (Build date: 2016-05-10T11:59:39+0000)

该错误在Web界面和curl中均发生.这可能是什么问题? SELECT查询工作正常.通过网络界面上传表单从文件中加载三元组也可以.附加问题:普通邮寄请求使用query=,而curl版本使用update=,为什么会有不同?

The error occurs both in the web interface and with curl. What could be the problem here? SELECT queries work without problems. Loading triples from a file through the web interface upload form also works. Additional question: the normal post request uses query= and the curl version uses update=, why is this different?

推荐答案

您要引用的文档是2008年 SPARQL更新提交 ,而不是实际的2013 SPARQL 1.1建议.推荐的是实际标准,提交的不是.

The document you're referencing is the 2008 SPARQL Update submission, not the actual 2013 SPARQL 1.1 recommendation. The recommendation is the actual standard, the submission is not.

更新(插入或删除)不是查询(选择,询问,构造),并且两种查询的语法不一定相同.您注意到(正确)在选择查询中WHERE是可选的,但这并不意味着它在插入中是可选的.插入有两种形式.有具有以下语法的INSERT DATA:

An update (insert or delete) isn't a query (select, ask, construct), and the syntax for the two kinds of query aren't necessarily the same. You note (correctly) that WHERE is optional in a select query, but that doesn't mean that it's optional in an insert. There are two forms of insert. There's INSERT DATA which has the syntax:

INSERT DATA  QuadData  

,其中有DELETE/INSERT,其语法为:

and there's DELETE/INSERT which has the syntax:

( WITH IRIref )?
( ( DeleteClause InsertClause? ) | InsertClause )
( USING ( NAMED )? IRIref )*
WHERE GroupGraphPattern

DeleteClause ::= DELETE  QuadPattern 
InsertClause ::= INSERT  QuadPattern 

因此,如果您使用的是INSERT {… },这就是DELETE/INSERT表单的InsertClause,您需要在WHERE…之后跟随它.由于您使用的是静态数据,因此您可能应该只使用INSERT DATA形式:

So if you're using INSERT { … }, then that's the InsertClause of a DELETE/INSERT form, and you need to follow it with WHERE …. Since you're using static data, you should probably just use the INSERT DATA form:

PREFIX dc: <http://purl.org/dc/elements/1.1/>
INSERT DATA { <http://example/egbook3> dc:title  "This is an example title" }

这篇关于sparql期望"where","using"之一.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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