搭建Jena Fuseki並執行SPARQL查詢


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM