适用于Apache Jena TripleStore的JavaScript [英] JavaScript for Apache Jena TripleStore

查看:70
本文介绍了适用于Apache Jena TripleStore的JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Apache Jena建立了一个TDB-Store,现在我想使用我商店中的数据来实现一些不错的可视化效果.因此,毕竟有必要使用JavaScript访问我的TDB.

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:

不. 1:运行Fuseki服务器,并在其端点(即http://localhost:3030/dataset/sparql)上运行sparql查询.如何使用js查询此终结点?

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?

不. 2:直接从js访问TDB.这可能吗?

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

在此先感谢FFoDWindow

Thanks in advance, FFoDWindow

推荐答案

我能够自己回答问题:

对于1号:

  1. 您需要照常运行Fuseki服务器. SPARQL-端点现在为http://localhost:3030/nameOfYourDataset/sparql.
  2. 现在该将您的查询编码为url友好格式,即使用encodeURIComponent函数.我这样做如下:

  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";

  • 现在使用ajax调用queryUrl,您将以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

    FFoDWindow

    这篇关于适用于Apache Jena TripleStore的JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆