I have wrote some SPARQL queries against DBPedia's SPARQL endpoint, because sometimes this endpoint is not available. I have downloaded some RDF files (e.g. counties.rdf).
How can I run my queries against the RDF file? I tried replacing the address of the endpoint with my local path but it does not work.
Example:
var url = "http://dbpedia.org/sparql"; == http://localhost/myfile/india.rdf
var query = "
PREFIX dbpedia2: <http://dbpedia.org/resource/>
PREFIX ABs: <http://dbpedia.org/ontology/>
SELECT ?capital
WHERE {
?s dbpedia2:India\"@en;\ abs:capital ?capital\
}";
I have not really used PHP and RDF together. Instead, I did it using Python. There we had a library called "rdflib" which can be used to load an RDF in an object, and then execute SPARQL queries on it.
I think there is something like this in PHP. After some "googling", I came by easyrdf which seems to be quite similar. Their documentation provides a bunch of examples in which I see something like "Making a SPARQL SELECT query". Hope it helps
Edit note: This example does not work for a local file. EasyRDF requires an http / https endpoint.