2

Given a SPARQL endpoint (which can be either SPARQL 1.0 or 1.1), say for example http://pt.dbpedia.org/sparql, how do I find which version of SPARQL it supports?

[One option is to try out a 1.1 feature such as aggregate functions and see it works but I guess there should be a better way to do this].

The SPARQL 1.1 Service Description specification says

SPARQL services made available via the SPARQL Protocol should return a service description document at the service endpoint when dereferenced using the HTTP GET operation without any query parameter strings provided. This service description must be made available in an RDF serialization, may be embedded in (X)HTML by way of RDFa [RDFA], and should use content negotiation [CONNEG] if available in other RDF representations

and further,

3.2.10 sd:supportedLanguage Relates an instance of sd:Service to a SPARQL language (e.g. Query and Update) that it implements. subPropertyOf: sd:feature domain: sd:Service range: sd:Language

3.3.3 sd:Language An instance of sd:Language represents one of the SPARQL languages, including specific configurations providing particular features or extensions. This document defines three instances of sd:Language: sd:SPARQL10Query, sd:SPARQL11Query, and sd:SPARQL11Update. type: rdfs:Class subClassOf: sd:Feature

But when I dereference most of the SPARQL endpoints, they just sends me an HTML SPARQL query editor.

UPDATE: HTML editor issue was because I didn't use proper content negotiation on the endpoint. But now the question is there a good way to differentiate between a SPARQL 1.0 endpoint and a SPARQL 1.1 endpoint that doesn't provide a service description?

There are some work done on discovering and monitoring SPARQL endpoints such as SPARQL Web-Querying Infrastructure: Ready for Action?, Discoverability of SPARQL Endpoints in Linked Open Data but I didn't see a straight-forward way of finding the version.

Nandana
  • 1,240
  • 8
  • 17
  • "But when I dereference most of the SPARQL endpoints, they just sends me an HTML SPARQL query editor." What endpoints have you been dereferencing? This works with, e.g., [DBpedia's SPARQL endpoint](http://dbpedia.org/sparql) and with the [Ordnance Linked Data Sparql endpoint](http://data.ordnancesurvey.co.uk/datasets/os-linked-data/explorer/sparql) – Joshua Taylor Apr 21 '15 at 12:10
  • Thanks. Yes, I should have used content negotiation. The endpoint is http://pt.dbpedia.org/sparql . It doesn't support content negotiation on the SPARQL endpoint such that it only has a HTML representation for GET operations. – Nandana Apr 21 '15 at 12:30

1 Answers1

1

The first thing that you should check is that when you're dereferencing the endpoint, you're asking for content in an RDF format, not the text/html, etc., that a web browser would specify by default, and that the endpoint isn't giving you certain outputs based on the user agent, etc. For instance, if you visit the DBpedia endpoint at http://dbpedia.org/sparql, you get an HTML query editor. However, if you request that page with the Accept header set to "application/rdf+xml", you'll get the service description. Without knowing what endpoints you're having trouble with, we can't really be much more help. This should work, but some endpoint doesn't do it, that's not really a technical problem that we can debug, especially if you don't tell us which endpoints you have problems with. Here's what this looks like using curl:

$ curl -H "Accept: application/rdf+xml" http://dbpedia.org/sparql 
<?xml version="1.0" encoding="utf-8" ?>
<rdf:RDF
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
        xmlns:sd="http://www.w3.org/ns/sparql-service-description#" >
  <rdf:Description rdf:about="http://dbpedia.org/sparql">
    <rdf:type rdf:resource="http://www.w3.org/ns/sparql-service-description#Service" />
    <sd:endpoint rdf:resource="http://dbpedia.org/sparql" />
    <sd:feature rdf:resource="http://www.w3.org/ns/sparql-service-description#UnionDefaultGraph" />
    <sd:feature rdf:resource="http://www.w3.org/ns/sparql-service-description#DereferencesURIs" />
    <sd:resultFormat rdf:resource="http://www.w3.org/ns/formats/SPARQL_Results_JSON" />
    <sd:resultFormat rdf:resource="http://www.w3.org/ns/formats/SPARQL_Results_XML" />
    <sd:resultFormat rdf:resource="http://www.w3.org/ns/formats/Turtle" />
    <sd:resultFormat rdf:resource="http://www.w3.org/ns/formats/N-Triples" />
    <sd:resultFormat rdf:resource="http://www.w3.org/ns/formats/N3" />
    <sd:resultFormat rdf:resource="http://www.w3.org/ns/formats/RDF_XML" />
    <sd:resultFormat rdf:resource="http://www.w3.org/ns/formats/SPARQL_Results_CSV" />
    <sd:resultFormat rdf:resource="http://www.w3.org/ns/formats/RDFa" />
    <sd:supportedLanguage rdf:resource="http://www.w3.org/ns/sparql-service-description#SPARQL10Query" />
    <sd:url rdf:resource="http://dbpedia.org/sparql" />
  </rdf:Description>

Here's a live version that uses d3's XmlHttpRequest functionality. (I know you can do this without libraries, but I've been using a lot of d3 lately.)

/** 
 * Make a GET request to dbpedia.org/sparql
 * and show the response in a PRE element.
 */
d3.xhr("http://dbpedia.org/sparql")
  .get(function(error,data) {
    console.log(error);
    console.log(data);
    d3.select("body")
      .append("pre")
      .text(data.response);
  });
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • Thanks! Yes, it solves the comment I had about sending a request to the SPARQL endpoint without content negotiation. Further, if a SPARQL endpoint sends me a service description, even if doesn't have the sd:Language information I can deduce that it might support SPARQL 1.1 as service descriptions were introduced in 1.1. But if there is no service description, is there a way to know whether a particular endpoint is a SPARQL 1.0 one? The endpoint I am concerned is http://pt.dbpedia.org/sparql. – Nandana Apr 21 '15 at 12:27
  • @Nandana Yes, that endpoint doesn't seem to return an appropriate RDF description. I'm not sure what's available for SPARQL 1.0. I think the [SPARQL protocol for RDF](http://www.w3.org/TR/rdf-sparql-protocol/) (for SPARQL 1.0) might be the closest thing you get. – Joshua Taylor Apr 21 '15 at 13:08