Assigning variables

If you want to construct RDF triples using a variable that is derived from retrieved data, e.g., through an arithmetical operation, you can add a BIND statement to the WHERE clause as follows:

PREFIX dbpedia: <>
PREFIX foaf: <>
PREFIX mo: <>

CONSTRUCT { ?track mo:runtime ?secs } 
WHERE { dbpedia:The_Beatles foaf:made ?album .
    ?album mo:record ?record .
    ?record mo:track ?track .
    ?track mo:duration ?duration .
    BIND ((?duration/1000) AS ?secs) .

In this way the object of mo:runtime will be given in seconds rather than milliseconds.

This work is a derivative of ‘Using Linked Data Effectively’ by The Open University (2014) and licensed under CC by 4.0 International Licence adapted and used by the University of Southampton.

Share this article:

This article is from the free online course:

Introduction to Linked Data and the Semantic Web

University of Southampton

Get a taste of this course

Find out what this course is like by previewing some of the course steps before you join: