SPARQL Query Service


The XAK SPARQL query service implements the SPARQL Protocol for RDF (14th September 2005) providing SPARQL query processing for RDF data available on the open internet.

The query processor extends the standard protocol to provide support for multiple output formats. At present this uses additional query parameters, although Content Negotiation will eventually be supported.

Base URL

The Base URL of the query service is:

Request Methods

Method Supported? Notes
GET Yes A GET of the Base URL without any parameters will return an HTML form suitable for experimenting with the query service
POST Yes Equivalent to GET. SPARQL Protocol notes that "[GET] should be used except in cases where the URL-encoded query exceeds practicable limits"

Request Parameters

The request parameters supported by this service, with the exception of format are specified in the SPARQL Protocol for RDF, see Section 2.2 HTTP Bindings.The table below summarises their use

Parameter Notes Required? Occurence
query URL encoded SPARQL query No. But this or query-uri parameter must be supplied, otherwise query form displayed 0/1
query-uri URL from which query can be fetched. Extension to SPARQL protocol No. But this or query parameter must be supplied, otherwise query form displayed 0/1
default-graph-uri Absolute URL of RDF data source(s) to populate the background graph Yes, if the query does not include a FROM clause 0 or more
named-graph-uri Absolute URL of RDF data source(s) to be used as named graphs No. Query may also refer to named graphs using the FROM NAMED clause 0 or more
format Format for results. Extension to SPARQL protocol. Values depend on type of query. See below. No 0 or 1
xslt-uri Absolute URL of XSLT stylesheet to apply to SELECT query results (ONLY). Extension to SPARQL protocol. No 0 or 1

Response Codes

As specified in the SPARQL protocol, the following HTTP response codes will be returned by this service:

Response Format

By default responses to SELECT queries from this service will conform to the SPARQL Query Results XML Format. As specified in that document, the mimetype will be application/sparql-results+xml.

In addition to this format, the service supports a superset of the SPARQL Protocol allowing a user agent to request responses in additional formats. See the following sections for notes on alternate output options for SELECT queries.

The CONSTRUCT and DESCRIBE query forms both produce RDF graphs. This service supports several RDF syntaxes.

The ASK query form is only available in the SPARQL Query Results format.

Error messages returned from the service are returned as XML documents, using the mime type application/xml. The documents consist of a single element containing an error message. See the sparql-protocol-types.xsd schema for definitions. (Note: at the time of writing the SPARQL protocol does not mandate particular response formats, just response codes.)

Additional Response Formats -- SELECT

Use the format parameter to select one of the following alternate output formats:

Format Value Description Mimetype
html HTML document containing query summary and tabular results text/html
json JSON serialization of results. Conforms to the draft specification Serializing SPARQL Query Results in JSON application/sparql-results+json
js Javascript serialization of results. Generates an HTML table with the CSS class sparql. The table contains a column indicating row number and additional columns for each query variable. Each query solution contributes one row of the table. Unbound variables are indicated with a non-breaking space in the appropriate table cells. application/javascript

The ASK query method also supports the json output option.

Additional Response Formats -- CONSTRUCT, DESCRIBE

The CONSTRUCT and DESCRIBE query forms both generate RDF graphs. The following output options are supported by specifying an appropriate value for the format parameter (Note: values are case-sensitive):

Format Values Description Mimetype
RDF/XML (default) RDF/XML
RDF/XML-ABBREV More human-readable RDF/XML output. Less efficient
N3 Tim Berners-Lee's N3 language
TURTLE Dave Beckett's Turse RDF Triple Language
Jena documentation


Coming Soon...

Implementation Notes

This service has been implemented using Jena 2.3.

Source of information