Skip to content

Instantly share code, notes, and snippets.

@jgeldart
jgeldart / gist:798413
Created January 27, 2011 11:59
Select and traverse style querying
dbowl = namespace("http://dbpedia.org/ontology/");
yago = namespace("http://dbpedia.org/class/yago/");
dbp = namespace("http://dbpedia.org/page/");
people = query("http://dbpedia.org/sparql")
.kind(dbowl("Person"))
.has(dbowl("birthPlace"))
.is(dbp("Argentina"))
.end().results(); // Without a callback, returns a pseudo-future (empty array until result is obtained, then the array of results)
golfAwardWinners = people.traverse([dbowl("award")]).filter(where().kind(yago("ProfessionalGolfTours"))).results();
@jgeldart
jgeldart / example-jquery-sparql-use.js
Created December 3, 2010 02:13
An example of using optional subqueries with jQuery SPARQL
$.sparql("http://services.data.gov.uk/education/sparql")
.prefix("sch-ont", "http://education.data.gov.uk/ontology/school#")
.select(["?name", "?address1", "?address2", "?town", "?postcode"])
.where("?school", "a", "sch-ont:School")
.where("sch-ont:establishmentName", "?name")
.where("sch-ont:districtAdministrative", "<http://education.data.gov.uk/placeholder-id/administrativeDistrict/City-of-London>;")
.optional()
.where("?school", "sch-ont:address", "?address")
.where("?address", "sch-ont:address1", "?address1")
.where("sch-ont:address2", "?address2")