Skip to content

Instantly share code, notes, and snippets.

@kwijibo
Last active December 21, 2015 00:48
Show Gist options
  • Save kwijibo/6222943 to your computer and use it in GitHub Desktop.
Save kwijibo/6222943 to your computer and use it in GitHub Desktop.

#Dynamic Linked Data

status: DRAFT,EXPERIMENTAL

Traditional Linked Data is not very "browsable" and does not provide a way to get from a resource to a list of things of the same type, or from a page about a book to a list of books by the same author.

SPARQL is a powerful query language, but it is difficult to write queries without knowledge of both the dataset, and SPARQL. It is not always practical to provide a SPARQL endpoint for every dataset that publishes as Linked Data.

This document describes a simple HTTP-based query system for Linked Data to fill the gap between static documents and SPARQL.

##Publishing

  • VoID should be discoverable from every document.
    • VoID should contain vann:preferredNamespacePrefix triples declaring which prefixes are supported in path queries
    • VoID should contain description of the licensing terms the dataset is available under
  • Formats: HTML and Turtle should be supported through content-negotiation. Other formats (JSON, XML, etc) are optional.

##Query Format

Queries are passed in the query string of the URL - after the ?

The query string is broken up into path queries and parameters by &.

Anything beginning in _ is a parameter .

Anything not beginning in a _ is a path query.

The query results should be the resources that match all of the path queries.

Parameters include:

  • _pageSize={positive integer} (number of results per page)
  • _page={integer} (page number)
  • _resource={URI or CURIE} (return a description of the given resource)
  • _related={URI or CURIE} (returns descriptions of resources which have the given resource's URI as a property value, ie: ?s ?p <{uri}> .)

Resolving CURIEs

CURIEs should be interpreted as full URIs using the namespace prefixes described in the dataset's VoID file, with vann:preferredNamespacePrefix.

Path Queries

Path queries consist of a property path and a value, in the form {property path}={value}.

The results are descriptions of resource from which the property path leads to the value.

A property path consists of one or more CURIE (or wildcards *), separated by /. eg: foaf:made/dc:subject.

A wildcard in a property path (eg: foaf:made/*=Tarzan) can match any property.

A value can be text, a CURIE or a URI. If the value has the form of a CURIE, it should be interpreted as the fully qualified URI. (If the value should not be interpreted as a CURIE, the : should be escaped like so: nota\:CURIE.)

eg: foaf:made/dc:subject=dbpedia:Politics

is equivalent to the SPARQL query:

DESCRIBE ?s { ?s foaf:made/dc:subject <http://dbpedia.org/resource/Politics> }

Comparison functions

The property path may be followed by a comparison function, with the following syntax: {property path};{comparison function}={value}

comparisons include:

  • _max returns resources where the value in the data is the same or less than the given value
  • _min returns resources where the value in the data is the same or more than the given value
  • _search returns resources where the value in the data matches a free text search for the given value

Examples

  • rdf:type=bibo:Book&dc:title;_search=Tarzan (books with 'Tarzan' in the title)
  • foaf:made/dc:date;_max=1670 (authors who published before 1671)
  • ex:born;_min=1870&ex:born;_max=1890 (anyone born 1870-1890)
  • *=dbpedia:Marmalade (anything with a link to dbpedia:Marmalade)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment