JavaScript for Apache Jena TripleStore

杀马特。学长 韩版系。学妹 提交于 2019-12-13 17:19:01

问题


i've build a TDB-Store with Apache Jena and now i want to use the data from my store to implement some nice visualizations. So after all it's necessary to access my TDB with JavaScript.

I guess, there are two possibilities to archieve this:

No. 1: Run a Fuseki Server and run sparql queries on it's endpoint (i.e. http://localhost:3030/dataset/sparql). How can i query this endpoint with js?

No. 2: Access the TDB directly from js. Is this possible?

Thanks in advance, FFoDWindow


回答1:


I was able to answer the question by myself:

For No 1.:

  1. You need to run your Fuseki-Server as usual. The SPARQL-endpoint is now http://localhost:3030/nameOfYourDataset/sparql.
  2. It's time to encode your query to an url-friendly format, i.e. with the encodeURIComponent-function. I did it as follows:

    var queryUrl = url_to_endpoint + "?query" + encodeURIComponent(query) + "&format=json";
    
  3. Now call queryUrl with ajax and you receive your result in json-format.

I guess No. 2 was kind of a silly question and the first method is the best way to obtain your data.

I hope this answer helps further reader. See you,

FFoDWindow



来源:https://stackoverflow.com/questions/39742693/javascript-for-apache-jena-triplestore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!