Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript for Apache Jena TripleStore

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

like image 587
malwin Avatar asked Sep 28 '26 20:09

malwin


1 Answers

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

like image 92
malwin Avatar answered Oct 02 '26 14:10

malwin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!