Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I consume a sparql endpoint - such as DBPedia in an iphone app

I am looking for tutorials on how to consume and parse data from a sparql endpoint such as DBPedia. I am new to semantic web and rdf and sparql. Would I just treat the response as XML and use one of the many third party xml parsers to read rdf input?

A link to a good tutorial for consuming sparql endpoints on the iphone would be great

like image 777
Antonio de Perio Avatar asked Jan 09 '12 12:01

Antonio de Perio


People also ask

How do I access DBpedia?

DBpedia Live SPARQL Endpoint: The DBpedia-Live SPARQL Endpoint can be accessed at http://live.dbpedia.org/sparql.

What are SPARQL endpoints?

A SPARQL Endpoint is a Point of Presence on an HTTP network that's capable of receiving and processing SPARQL Protocol requests. It is identified by a URL commonly referred to as a SPARQL Endpoint URL.

What is DBpedia SPARQL?

SPARQL (pronounced "sparkle" /ˈspɑːkəl/, a recursive acronym for SPARQL Protocol and RDF Query Language) is an RDF query language—that is, a semantic query language for databases—able to retrieve and manipulate data stored in Resource Description Framework (RDF) format.

Where is SPARQL used?

SPARQL can be used to express queries across diverse data sources, whether the data is stored natively as RDF or viewed as RDF via middleware. SPARQL contains capabilities for querying required and optional graph patterns along with their conjunctions and disjunctions.


1 Answers

You send the query as a HTTP GET request, and parse the result (usually XML or JSON, you can request either) using an XML or JSON parser.

For example the query:

http://dbpedia.org/sparql?query=SELECT+DISTINCT+?concept+WHERE+{+?s+a+?concept+}+LIMIT+50

Will run the SPARQL query:

SELECT DISTINCT ?concept
WHERE {
    ?s a ?concept .
} LIMIT 50

And return the results in XML.

You can test this in curl with:

$ curl -g 'http://dbpedia.org/sparql?query=SELECT+DISTINCT+?concept+WHERE+{+?s+a+?concept+}+LIMIT+50'

If you set the Accept: header you can control the return type, e.g. in curl:

$ curl -g -H 'Accept: application/json' 'http://dbpedia.org/sparql?query=SELECT+DISTINCT+?concept+WHERE+{+?s+a+?concept+}+LIMIT+50'
like image 62
Steve Harris Avatar answered Oct 27 '22 00:10

Steve Harris