Question

I want to query the DBLP database using this end point:

http://dblp.l3s.de/d2r/snorql/

My code snippet:

String st = "";
String qry = "";
String uri_V;
String dguri_V;

uri_V = "http://dbpedia.org/sparql";
dguri_V = "http://dbpedia.org";


// Modify if need......
//String ns = "\""+TextBox1.Text.ToString()+"\"";
// String qry = "SELECT DISTINCT ?name WHERE { ?person foaf:name ?name.FILTER regex(str(?name),"+ns+").}";
if (radiosrch.SelectedIndex == 0)
{
    qry = "SELECT ?title WHERE {?game <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:First-person_shooters> .?game foaf:name ?title .}ORDER by ?title";
}
else// if (radiosrch.SelectedIndex == 1) 
{
    // qry= "query for publisher."
    qry = "SELECT DISTINCT ?Concept WHERE {[] a ?Concept} LIMIT 10";
}

//Common
SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(new Uri(uri_V), dguri_V);
SparqlResultSet results = endpoint.QueryWithResultSet(qry);
foreach (SparqlResult result in results)
{
    Console.WriteLine(result.ToString());
    st = st + result.ToString() + "\n";
}
TextBox3.Text = st.ToString();

It's working for dbpedia but I can't find the uri_v, dguri_v to query DBLP database with an endpoint.

Was it helpful?

Solution

If you ever come across a SNORQL UI for an endpoint you can always find the actual SPARQL endpoint URI from the Page Title and Header, for your example note it says the following in both places:

Snorql: Exploring http://dblp.l3s.de/d2r/sparql

The URI here is the one you want for your uri_v variable.

Often the default graph (your dguri_v) argument is not required at all, it just happens to be required for DBPedia. With just the SPARQL endpoint URI you should now be able to query your desired endpoint, make sure to use the constructor for SparqlRemoteEndpoint that only takes the endpoint URI as the argument.

Edit

SNORQL is a UI and as such it is not a SPARQL endpoint, it is merely a HTML+JS wrapper over an endpoint.

As described above the UI will show the URI of the actual SPARQL endpoint that it is querying. This is the URI you need if you want to write code that queries the endpoint (regardless of the toolkit/API you are using).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top