1. 下载Jena Fuseki:http://jena.apache.org/download/index.cgi
2. 运行服务
windows解压后双击fuseki-server.bat
linux解压后运行命令
java -jar fuseki-server.jar --update --loc /data/apache-jena-fuseki-3.5.0/run/databases/DB /ds
“–update”表示允许修改;“–loc”后面的参数,表示存放Fuseki数据的文件夹路径; “/ds”表示Fuseki服务的名字
程序启动后默认在3030端口运行,http://localhost:3030
3. 导入rdf文件
新建test.rdf,复制以下内容
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#">
<rdf:Description rdf:about="http://somewhere/MattJones/">
<vCard:FN>Matt Jones</vCard:FN>
<vCard:N rdf:parseType="Resource">
<vCard:Family>Jones</vCard:Family>
<vCard:Given>Matthew</vCard:Given>
</vCard:N>
</rdf:Description>
<rdf:Description rdf:about="http://somewhere/RebeccaSmith/">
<vCard:FN>Becky Smith</vCard:FN>
<vCard:N rdf:parseType="Resource">
<vCard:Family>Smith</vCard:Family>
<vCard:Given>Rebecca</vCard:Given>
</vCard:N>
</rdf:Description>
<rdf:Description rdf:about="http://somewhere/JohnSmith/">
<vCard:FN>John Smith</vCard:FN>
<vCard:N rdf:parseType="Resource">
<vCard:Family>Smith</vCard:Family>
<vCard:Given>Jones</vCard:Given>
</vCard:N>
</rdf:Description>
<rdf:Description rdf:about="http://somewhere/SarahJones/">
<vCard:FN>Sarah Jones</vCard:FN>
<vCard:N rdf:parseType="Resource">
<vCard:Family>Jones</vCard:Family>
<vCard:Given>Sarah</vCard:Given>
</vCard:N>
</rdf:Description>
</rdf:RDF>
在fuseki界面新建database,并导入以上xml,
3. 执行SPARQL查询
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?x
WHERE { ?x <http://www.w3.org/2001/vcard-rdf/3.0#FN> "John Smith" }
参考:https://blog.csdn.net/svenhuayuncheng/article/details/78829035