20

我是语义网技术的初学者,我的问题可能是一个非常基本的问题,但我真的很难弄清楚。我有一个从 XML 创建的 RDF 文件,并使用 w3.org RDF VALIDATOR 对其进行了验证。我的问题是如何使用 SPARQL 对我的 RDF 文档运行查询。在线资源http://demo.openlinksw.com/sparql不起作用,我不知道什么或如何找到有关此的信息。

4

2 回答 2

19

您可以使用Fuseki设置您自己的本地 SPARQL 端点。Fuseki 是Apache Jena 项目的一部分,但可以作为独立应用程序下载(在上面的链接中)。

使用Fuseki,您可以(除其他外)

  1. 加载本地 RDF 数据集
  2. 使用该数据集
    • 通过(默认情况下)将此数据公开为SPARQL 端点http://localhost:3030/
    • 使用基于Web 的查询表单http://localhost:3030/sparql.html

这意味着您可以使用 Fuseki 来简单地使用基于 Web 的表单查询您的数据集,或者使用任何通过 http 查询 SPARQL 端点的应用程序来查询您的数据集。

就个人而言,我目前正在开发一个通过 SPARQL 端点分析数据集的应用程序。我使用 Fuseki 设置一个本地 SPARQL 端点,其中包含可以运行和测试我的应用程序的示例数据。


如何?

Fuseki 的基本功能相当容易使用。下面的行将启动服务器(SPARQL 端点)。

java -jar fuseki-server.jar --config=yourConfig.ttl

该文件yourConfig.ttl是一个 RDF 文件(海龟序列化格式)。要设置一个将 RDF 文件加载到内存的基本服务器,只需写入(至少替换数据集文件的路径):

# Attention: I have omitted the @prefix declarations

[] rdf:type fuseki:Server ;
   fuseki:services (
 <#yourService>
) .

<#yourService> rdf:type fuseki:Service ;
fuseki:name                     "yourService" ;
fuseki:serviceQuery             "query" ;
fuseki:serviceReadGraphStore    "get" ;
fuseki:dataset                   <#yourDataset> ;
.

<#yourDataset>    rdf:type ja:RDFDataset ;
rdfs:label "a label for your dataset" ;
ja:defaultGraph 
  [ rdfs:label "yourDataset.rdf" ;
    a ja:MemoryModel ;
    ja:content [ja:externalContent <file:Path/To/yourDataset.rdf> ] ;
  ] ;
.

于 2012-12-17T02:08:04.440 回答
4

There are several tools you can use to do this. Of course, there are the RDF frameworks like Apache Jena or OpenRDF Sesame (Java), or dotNetRdf (.Net), to name just three. Most if not all offer installation and getting started instructions. These are powerful solutions that you will definitely need if you go further with SW technologies and need to build your own code on top of RDF data sources.

But for trying out some simple queries, it's perhaps easier to try something like the Sesame Windows Client (SWC) tool. This is a simple graphical Windows desktop application that you can use to create a repository, load data in it, and then do SPARQL queries, without any programming or advanced configuration (disclaimer: I wrote this tool).

于 2012-12-16T18:39:38.557 回答