Skip to content

Instantly share code, notes, and snippets.

@jgeldart
Created December 3, 2010 02:13
Show Gist options
  • Save jgeldart/726473 to your computer and use it in GitHub Desktop.
Save jgeldart/726473 to your computer and use it in GitHub Desktop.
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")
.where("sch-ont:postcode", "?postcode")
.where("sch-ont:town", "?town")
.end()
.orderby("?name")
.execute(cbfunc);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment