Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example SPARQL query for PROD
library(SPARQL)
library(sp)
d <- SPARQL(url='http://api.talis.com/stores/jisc-prod-dev1/services/sparql',
query='PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX jisc: <http://www.rkbexplorer.com/ontologies/jisc#>
PREFIX doap: <http://usefulinc.com/ns/doap#>
PREFIX prod: <http://prod.cetis.ac.uk/vocab/>
PREFIX mu: <http://www.jiscmu.ac.uk/schema/muweb/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT DISTINCT ?projectID ?Project ?Project_Name ?Programme ?Strand ?Lead_Inst_ID ?Lead_Inst xsd:float(?lat) xsd:float(?long) ?Desc
WHERE {
?projectID a doap:Project .
OPTIONAL { ?projectID prod:programme ?Programme } .
OPTIONAL { ?projectID prod:strand ?Strand } .
OPTIONAL { ?projectID jisc:short-name ?Project } .
OPTIONAL { ?projectID doap:name ?Project_Name } .
?projectID doap:vendor ?Lead_Inst_ID .
?Lead_Inst_ID rdfs:label ?Lead_Inst .
OPTIONAL {
?Lead_Inst_ID owl:sameAs ?fbID .
?muID owl:sameAs ?fbID .
?muID geo:lat ?lat .
?muID geo:long ?long .
}
OPTIONAL {
?projectID doap:shortdesc ?Desc .
}
} ',
ns=c('rdf','<http://www.w3.org/1999/02/22-rdf-syntax-ns#>',
'rdfs','<http://www.w3.org/2000/01/rdf-schema#>',
'owl','<http://www.w3.org/2002/07/owl#>',
'xsd','<http://www.w3.org/2001/XMLSchema#>',
'foaf','<http://xmlns.com/foaf/0.1/>',
'jisc','<http://www.rkbexplorer.com/ontologies/jisc#>',
'doap','<http://usefulinc.com/ns/doap#>',
'prod','<http://prod.cetis.ac.uk/vocab/>',
'mu','<http://www.jiscmu.ac.uk/schema/muweb/>',
'geo','<http://www.w3.org/2003/01/geo/wgs84_pos#>',
'dc','<http://purl.org/dc/elements/1.1/>'),format="xml", lossy=F)
prod <- as.data.frame(d$results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment