What?
A simple guide usable by any Javascript developer seeking to exploit SPARQL without hassles.
Why?
SPARQL is a powerful query language, results serialization format, and an HTTP based data access protocol from the W3C. It provides a mechanism for accessing and integrating data across Deductive Database Systems (colloquially referred to as triple or quad stores in Semantic Web and Linked Data circles) -- database systems (or data spaces) that manage proposition oriented records in 3-tuple (triples) or 4-tuple (quads) form.
How?
SPARQL queries are actually HTTP payloads (typically). Thus, using a RESTful client-server interaction pattern, you can dispatch calls to a SPARQL compliant data server and receive a payload for local processing.
Steps:
- Determine which SPARQL endpoint you want to access e.g. DBpedia or a local Virtuoso instance (typically: http://localhost:8890/sparql).
- If using Virtuoso, and you want to populate its quad store using SPARQL, assign "SPARQL_SPONGE" privileges to user "SPARQL" (this is basic control, more sophisticated WebID based ACLs are available for controlling SPARQL access).
Script:
/* Demonstrating use of a single query to populate a # Virtuoso Quad Store via Javascript. *//*
HTTP URL is constructed accordingly with JSON query results format as the default via mime type.
*/function sparqlQuery(query, baseURL, format) {
if(!format)
format="application/json";
var params={
"default-graph": "", "should-sponge": "soft", "query": query,
"debug": "on", "timeout": "", "format": format,
"save": "display", "fname": ""
};
var querypart="";
for(var k in params) {
querypart+=k+"="+encodeURIComponent(params[k])+"&";
}
var queryURL=baseURL + '?' + querypart;
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
}
else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",queryURL,false);
xmlhttp.send();
return JSON.parse(xmlhttp.responseText);
}/*
setting Data Source Name (DSN)
*/var dsn="http://dbpedia.org/resource/DBpedia";
/*
Virtuoso pragma "DEFINE get:soft "replace" instructs Virtuoso SPARQL engine to perform an HTTP GET using the IRI in FROM clause as Data Source URL with regards to
DBMS record inserts
*/var query="DEFINE get:soft \"replace\"\nSELECT DISTINCT * FROM <"+dsn+"> WHERE {?s ?p ?o}";
var data=sparqlQuery(query, "/sparql/");
Output
Place the snippet above into the <script/> section of an HTML document to see the query result.
Conclusion
JSON was chosen over XML (re. output format) since this is about a "no-brainer installation and utilization" guide for a Javascript developer that already knows how to use Javascript for HTTP based data access within HTML. SPARQL just provides an added bonus to URL dexterity (delivered via URI abstraction) with regards to constructing Data Source Names or Addresses.
It's amazing.I like it very much.
Posted by: Chicago Cubs jerseys | June 16, 2011 at 05:43 AM
let's join our hands together to stop this kind of wrong doings. It may risk lives in the future if we just let them continue.
Posted by: moncler jackets | December 08, 2011 at 07:43 AM
Our portal is ready to give you the information about Here we have few themed pictures:
Here is materials about , only at our site. See it in details:
Our portal is best in the field of work and knowledge about . More details in those pictures:
This site is devoted to and answering on a question –how to work and earn with . Here we have few themed pictures:
Our site will provide you with all necessary data in sphere of . See it in details:
If you want to understand in and you should necessarily visit our portal. Besides only at our web-site you can find such detailed pictures:
With occurrence of a specialized portal , became more accessible. Your age and experience not a hindrance because everybody can learn. Here we have few themed pictures:
You can find analog of at our site. More details in those pictures:
There were difficulties with , do not hesitate – ask about See it in details:
On a theme you will find fuller information on our web site. See it on the following pictures:
[url=http://auto-leave.com/cars2/2007-bmw-parts-manual/gmc-medium-duty-truck-parts.html]gmc medium duty truck parts[/url]
[url=http://auto-leave.com/cars5/honda-goldwing-1200-1986-parts/sitemap37.html]auto site[/url]
[url=http://auto-leave.com/cars3/old-ford-parts/sitemap4.html]auto site[/url]
[url=http://auto-leave.com/cars2/2007-bmw-parts-manual/sitemap8.html]auto site[/url]
[url=http://auto-leave.com/cars3/old-ford-parts/mitsubishi-dealer-only-parts.html]mitsubishi dealer only parts[/url]
[url=http://auto-leave.com/cars2/2007-bmw-parts-manual/car-park-dogging.html]car park dogging[/url]
[url=http://auto-leave.com/cars2/2007-bmw-parts-manual/sitemap14.html]auto site[/url]
[url=http://auto-leave.com/cars2/2007-bmw-parts-manual/sitemap6.html]auto site[/url]
[url=http://auto-leave.com/cars2/2007-bmw-parts-manual/compare-online-car-insurance-uk.html]compare online car insurance uk[/url]
[url=http://auto-leave.com/cars2/2007-bmw-parts-manual/lowest-auto-insurance-prices.html]lowest auto insurance prices[/url]
korenetorpi981
Materials of our portal will be useful to you at work with and themes. Pay attention to pictures on this theme:
If you search for a materials about you have visited the right place. It becomes more clearly on the pictures:
We will solve your problems with . It becomes more clearly on the pictures:
Actual meanings about and can be received with use of special devices. Those images will help you to understand:
You can find our site in the Internet by words: . Pay attention to pictures on this theme:
Our site will help you to orient with all moments connected with . Besides that, only at our web-site you can find such detailed pictures:
Our resource has all data on interesting to you theme . Pay attention to pictures on this theme:
Enter in a line of search next words and you will get on our site. More details in those pictures:
Our site will tell to you how better to use , and also we will be glad to answer on your questions. It becomes more clearly on the pictures:
We will tell and show you all about , with pleasure Here we have few themed pictures:
Posted by: Bpmhalrqxz | December 12, 2011 at 04:01 AM