#include <rasqal.h>
rasqal_world*world=rasqal_new_world();
rasqal_query_results *results;
raptor_uri *base_uri=raptor_new_uri("http://example.org/foo");
rasqal_query *rq=rasqal_new_query(world,"rdql",NULL);
const char *query_string="select * from <http://example.org/data.rdf>";
rasqal_query_prepare(rq,query_string,base_uri);
results=rasqal_query_execute(rq);
while(!rasqal_query_results_finished(results)) {
for(i=0;i<rasqal_query_results_get_bindings_count(results);i++) {
const char *name=rasqal_query_results_get_binding_name(results,i);
rasqal_literal *value=rasqal_query_results_get_binding_value(results,i);
/* ... */
}
rasqal_query_results_next(results);
}
rasqal_free_query_results(results);
rasqal_free_query(rq);
raptor_free_uri(base_uri);
rasqal_free_world(world);
cc prog.c -o prog `pkg-config rasqal --cflags` `pkg-config rasqal --libs`
Rasqal uses the libraptor(3) library for providing URI handling, WWW content retrieval and other support functions.
SPARQL Query Results XML Format, Jeen Broekstra and Dave Beckett (eds), W3C Recommendation, 15 January 2008. http://www.w3.org/TR/2008/REC-rdf-sparql-XMLres-20080115/
RDQL - A Query Language for RDF, Andy Seaborne, W3C Member Submission 9 January 2004 http://www.w3.org/Submission/2004/SUBM-RDQL-20040109/