如何使用 Jena 查询/更新远程 RDF 端点

发布于 2024-09-14 20:45:03 字数 1044 浏览 11 评论 0原文

我想通过 http 将更新发送到远程端点。 我发现定式就是这样一个端点。

但是,如果我只知道端点的 uri,如何向此端点发送更新查询?

// To do a select-query you can use this:
QueryExecution qe = QueryExecutionFactory.sparqlService(serviceURI, query);

// (Sidenote:) does the next line have the desired effect of setting the binding?
// After all, sparqlService has no alternative with initialBindang as parameter
qe.setInitialBinding(initialBinding);

result = qe.execSelect();

// But updates do not support this kind of sparqlService method
// Illegal:
// UpdateAction.sparqlServiceExecute(serviceURI, query);
// I can use the following:
UpdateAction.parseExecute(updateQuery, dataset, initialBinding);
// But dataset is a Dataset object, not the uri.

// I don't believe this is the correct way to overcome this:
Dataset dataset = DatasetFactory.create(serviceURI);

否则,我想听听如何对仅已知 URI 的端点进行远程更新查询。

更新: 最后求助于当地的jena。这种 RDF 端点接受插入和删除语句。 我没有成功找到可以接受修改查询的远程 RDF 端点。

I would like to send updates to a remote endpoint over http.
I have found that joseki serves as such an endpoint.

However, how do i send update queries to this endpoint, if I only know the uri of the endpoint?

// To do a select-query you can use this:
QueryExecution qe = QueryExecutionFactory.sparqlService(serviceURI, query);

// (Sidenote:) does the next line have the desired effect of setting the binding?
// After all, sparqlService has no alternative with initialBindang as parameter
qe.setInitialBinding(initialBinding);

result = qe.execSelect();

// But updates do not support this kind of sparqlService method
// Illegal:
// UpdateAction.sparqlServiceExecute(serviceURI, query);
// I can use the following:
UpdateAction.parseExecute(updateQuery, dataset, initialBinding);
// But dataset is a Dataset object, not the uri.

// I don't believe this is the correct way to overcome this:
Dataset dataset = DatasetFactory.create(serviceURI);

Otherwise I would like to hear how to do remote update queries to endpoints for which only the URI is known.

Update:
Resorted to a local jena in the end. This kind of RDF-endpoint accepts insert and delete statements.
I did not succeed in finding a remote RDF-endpoint that would accept modifying queries.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不知所踪 2024-09-21 20:45:03

否则我想听听如何
对端点进行远程更新查询
仅 URI 已知。

根据端点服务器的不同,处理方式略有不同。有一个 sparql/update 协议草案。但由于它是草案并且相当新的支持是一个小变体。

一般来说,您可以编写 sparql 更新查询,就像编写 SQL 插入或更新语句一样。

更新命令有修改、插入、删除、加载、清除,但并非每个实现都支持所有这些命令。

由于端点通常是公共的,因此在允许操作之前通常需要进行一些身份验证,这在规范中没有定义,因此是特定于实现的。

建议更新语句使用不同的 URL,以便可以使用 http 身份验证。 4store,使用 /sparql 进行查询,使用 /update 进行更新查询。

W3C 草案提供了一些关于如何构造 sparql 更新查询的示例

Otherwise I would like to hear how to
do remote update queries to endpoints
for which only the URI is known.

This is handled a little differently depending on the endpoint server. There is a draft sparql/update protocol. But as it is draft and fairly new support is a little variant.

Genrally you can write sparql update queries a little like you would write SQL insert or update statements.

The update commands are Modify, Insert, Delete, Load, Clear but not every imlpementation supports all of these.

As endpoints are often public there is usually some authentication needed before the action is allowed, this is not defined in the spec so is implementation specific.

It is advised that a different URL is used for update statements so that http authentication can be used. 4store, uses /sparql for queries and /update for update queries.

The W3C draft has some examples of how to construct sparql update queries.

只是我以为 2024-09-21 20:45:03

Joseki 不支持远程更新。您可能应该看看它的后继者 Fuseki,它支持 SPARQL 更新。

Joseki doesn't support remote updates. You probably should have a look at its successor, Fuseki, which supports SPARQL Update.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文