问题
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.:
- You need to run your Fuseki-Server as usual. The
SPARQL
-endpoint is nowhttp://localhost:3030/nameOfYourDataset/sparql
. 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";
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