Skip to content
SPARQL-LD: A SPARQL Extension for Fetching and Querying Linked Data
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

SPARQL-LD: A SPARQL Extension for Fetching and Querying Linked Data

This Jena ARQ SERVICE extension allows to fetch, query and integrate in the same SPARQL query:

  • data stored in the (local) endpoint
  • data coming from online RDF files (in any standard format)
  • data embedded in Web pages as RDFa
  • data coming from JSON-LD files
  • data coming from dereferenceable URIs
  • data (in RDF) dynamically created by a Web Service (Web API)
  • data coming by querying other SPARQL endpoints

by simply using the SERVICE operator of SPARQL 1.1 Federated Query.

A distinctive characteristic of SPARQL-LD is that it enables to fetch and query even data in datasets returned by a portion of the query, i.e. discovered at query-execution time.

SPARQL-LD is actually a generalization of SPARQL in the sense that every query that can be answered by the original SPARQL can be also answered by SPARQL-LD. Specifically, if the IRI given to the service operator corresponds to a SPARQL endpoint, then it works exactly as the original SPARQL (the remote endpoint evaluates the query and returns the result). Otherwise, instead of returning an error (and no bindings), it tries to fetch and query the triples that may exist in the given resource.

SPARQL-LD has been tested with Jena 2.13.0 ARQ (nevertheless, it may also work with other Jena ARQ releases).


SPARQL endpoints that support SPARQL-LD are available in the following links:

Related publications

P. Fafalios, T. Yannakis and Y. Tzitzikas,
"Querying the Web of Data with SPARQL-LD", 
20th International Conference on Theory and Practice of Digital Libraries (TPDL'16), 
Hannover, Germany, September 5-9, 2016


P. Fafalios and Y. Tzitzikas,
"SPARQL-LD: A SPARQL Extension for Fetching and Querying Linked Data", 
14th International Semantic Web Conference (Demo Paper) - ISWC'15, 
Bethlehem, Pennsylvania, USA, October 11-15, 2015 


T. Yannakis, P. Fafalios, and Y. Tzitzikas,
"Heuristics-based Query Reordering for Federated Queries in SPARQL 1.1 and SPARQL-LD", 
2nd Workshop on Querying the Web of Data (QuWeDa), in conjunction with the 15th Extended Semantic Web Conference (ESWC'18), 
Heraklion, Greece, June 3-7, 2018


Example Query

The following query can be answered by an implementation of SPARQL-LD. The query returns all co-authors of Pavlos Fafalios (main contributor of this repository) together with the number of their publications and the number of different conferences in which they have a publication. Notice that this query combines and integrates: i) data embedded in the HTML Web page as RDFa (lines 3-4), ii) data coming from dereferenceable URIs derived at query-execution time (lines 5-6), and iii) data coming by querying another endpoint (lines 7-9). Note also that this query can be answered by any endpoint that implements this extension (independently of its "local" contents).

1.  SELECT DISTINCT ?authorURI (count(distinct ?paper)  AS ?numOfPapers)
2.                             (count(distinct ?series) AS ?numOfDiffConfs) WHERE {
3.    SERVICE <> {
4.      ?p <> ?authorURI }
5.    SERVICE ?authorURI { 
6.      ?paper <> ?authorURI }
7.    SERVICE <> {
8.      ?p2 <> ?authorURI .
9.      ?p2 <> ?series  }
10. } GROUP BY ?authorURI ORDER BY ?numOfPapers

Source code

For implementing SPARQL-LD, we have created the following 4 classes:

  • com.hp.hpl.jena.sparql.engine.http.ReadRDFFromIRI
  • com.hp.hpl.jena.sparql.engine.http.ResourcesCache
  • com.hp.hpl.jena.sparql.engine.http.EndpointsIndex
  • arq.SPARQL_LD_QueryExamples

We have also updated the following 2 classes of Jena 2.13.0 ARQ:

  • com.hp.hpl.jena.sparql.engine.QueryExecutionBase
  • com.hp.hpl.jena.sparql.engine.http.Service

This repository contains only the above 6 classes. We also provide a zip containing the original Jena 2.13.0 ARQ source code (as downloaded from in April 17, 2015) as well as the extended, already built, Jena ARQ JAR file (jena-arq-2.13.0_SPARQL-LD-1.0.jar).


  • Download the original Jena 2.13.0 ARQ source code
  • Add the 4 new classes
  • Replace the 2 updated classes
  • Add the endpoints.lst file to the project folder (same level as pom.xml)
  • Add the following dependency to pom.xml (which allows to load and query RDFa data):
  • Build the sources
  • Try to run the main class "arq.SPARQL_LD_QueryExamples"


  • Directly use the provided (already built) extended Jena ARQ jar:


You can’t perform that action at this time.