SPARQL Demo
From n² wiki
Demonstration query form running against various Talis Platform stores.
Contents |
[edit] What it Does
The demo form allow you to query the data contained in the Platform stores. This demo is merely a wrapper around a SPARQL endpoint, creating the query URI and formatting the results to make them human-friendly.
[edit] Why SPARQL?
SPARQL offers a simple, standard way of querying an RDF store.
"Trying to use the Semantic Web without SPARQL is like trying to use a relational database without SQL," explained Tim Berners-Lee, W3C Director. "SPARQL makes it possible to query information from databases and other diverse sources in the wild, across the Web."
There are already 14 known implementations of SPARQL, many of which are open source.
The suite of specifications which describe RDF became W3C Recommendations in 2004, and the SPARQL specifications became Recommendations in January 2008. There are a multitude of applications using RDF, and a wide range of development tools and programming APIs.
[edit] How it Works
The standard way of running a SPARQL query against an RDF store is to encode the query as a single parameter in the query part of a URI (called "query"). The main part of the URI will be a SPARQL endpoint, exposed by a store. Any reserved characters in the query text need to be URL-escaped (for example the ':' character becomes '%3A'), hence the illegible URIs. But the operation is a simple HTTP GET, of the form:
GET /stores/danja-dev1/services/?query=<EncodedQuery> HTTP/1.1
Host: api.talis.com
When you paste your query into the form, select a store and click "Run Query", a little Javascript in the HTML page converts this information into a single URI, which is used in a HTTP GET. A simple piece of PHP server-side separates the query data and the selected store from that URI, and re-submits it to the appropriate SPARQL endpoint (different Platform stores have different endpoints). SPARQL Results Format is XML, so the results from the query are passed through an XSLT stylesheet to convert them to HTML for viewing.
The PHP and XSLT is available as source code.
Credit: this demo uses Morten Frederikson's results XSLT
[edit] SPARQL Resources
- SPARQL Specification
- SPARQL reference card
- SPARQL Tutorial
- Search RDF data with SPARQL
- W3C Press Release
[edit] Talis Platform Resources
- n-squared home (this Wiki)
- n2-dev mailing list
- Talis Platform (corporate) home page
- Talis home page

