LDPath Query Language

LDPath is a simple path-based query language, similar to XPath or SPARQL Property Paths, that is particularly well-suited for querying and retrieving resources from the Linked Data Cloud by following RDF links between resources and servers.

For example, the following path query would select the names of all friends of the context resource:

foaf:knows / foaf:name :: xsd:string

Read the full language specification for further details. Before dontated to the ASF, LDPath (formally known as RDFPath) was hosted on Google Code.


LDPath library is a collection of generic libraries that are independent of the underlying RDF implementation. Currently, there are backends for sesame, for RDF files, and for Linked Data. You can easily implement your own backends by implementing a straightforward interface (RDFBackend).

LDPath can serve many different purposes. It can e.g. serve as

  • a simple query language for selecting nodes or values in your own triple store programmatically from Java
  • a query language for transparently querying resources in the Linked Data Cloud and following links between datasets
  • a foundation for templating languages to render results based on RDF or Linked Data
  • a foundation for building a semantic search index (used e.g. in the Linked Media Framework and in Apache Stanbol)
  • a query language for experimenting with the Linked Data Cloud


The LDPath project consists of a collection of modules that can be combined as needed. We have grouped the modules in core modules, backends, and extensions. Modules are available in our Maven repository, see MavenArtifacts.

@@TODO@@: this needs to be updated

Core Modules

The following modules are the core modules of LDPath and are needed in every situation:

  • ldpath-api: contains interfaces used by the language; needed for custom extensions
  • ldpath-core: contains the core, backend-independent implementation of the LDPath language, including parser and evaluator; expects some backend implementation to be present.

Backend Modules

We provide a number of backends that are ready-to-use in your own projects. Implementing a backend is usually straightforward and involves mainly impementing the RDFBackend interface. RDFBackend makes use of Java Generics, so you are able to always use the data model of your backend directly. The following backends are provided by the distribution:

  • ldpath-backend-sesame: a generic backend implementation for Sesame repositories. A Sesame repository can be passed over on initialisation
  • ldpath-backend-jena: a generic backend implementation for Jena models. A Jena model can be passed over on initialisation
  • ldpath-backend-file: a file-based backend implementation allowing you to query the contents of an RDF file
  • ldpath-backend-linkeddata: a sophisticated backend implementation that queries and caches resources on the Linked Data Cloud

Extension Modules

Based on LDPath, we have implemented a number of extension modules. Some are part of other projects like the Linked Media Framework or Apache Stanbol. Part of the LDPath project itself are currently the following modules:

  • ldpath-template: implements an extension of the FreeMarker template engine that allows constructing templates with LDPath statements for inserting and iterating over values (example template); this module is backend-independent
  • ldpath-template-linkeddata: a backend implementation for ldpath-template that allows querying over the Linked Data Cloud; provides only a command-line tool for processing templates


Check the LDPath language specification, a more detailed introduction about the language constructs is available on the wiki.


The library is provided as Maven artifact, you you would need to declare a dependency like: