Skip to Navigation

RDF

From Data.gov.uk

Jump to: navigation, search

RDF stands for the Resource Description Framework: it's a model for describing resources -- anything that has a URI. A number of schemas, vocabularies and ontologies exist that provide a framework for these descriptions. RDF data that implements one or more of these rule sets can be expected to have certain properties and relationships as described by those rules, allowing the data to be manipulated in predictable ways.

Contents

RDF Model

RDF is a very simple model: everything is described using statements which are short sentences like:

Nonsuch Primary School is in the local authority ward of Barley Green.

or

Nonsuch Primary School has a free school meals percentage of 47.

These statements are split into three parts: the subject, which is what the statement is about, the predicate or property of that subject that the statement talks about, and the object which is the value of that property for the subject. We can split the sentences above down into these parts as follows:

subjectpredicateobject
Nonsuch Primary School local authority ward Bartley Green
Nonsuch Primary School free school meals percentage 47

The things that are mentioned within these statements -- subjects, predicates and objects -- are usually named using URIs. The main exception is that if a value is something like a number or a date they are represented as numbers or dates. In the case of the statements above, the number 47 is obviously just a number, but we have URIs for:

the subject 'Nonsuch Primary School'
http://education.data.gov.uk/id/school/103335
the object 'Bartley Green'
http://statistics.data.gov.uk/id/local-authority-ward/00CNGU
the predicate 'local authority ward'
http://education.data.gov.uk/def/school/administrativeWard
the predicate 'free school meals percentage'
http://education.data.gov.uk/def/school/FSMPercentage

And the RDF model would actually contain:

subjectpredicateobject
http://education.data.gov.uk/id/school/103335 http://education.data.gov.uk/def/school/administrativeWard http://statistics.data.gov.uk/id/local-authority-ward/00CNGU
http://education.data.gov.uk/id/school/103335 http://education.data.gov.uk/def/school/FSMPercentage 47

Importantly, the RDF model can also contain statements about each of these things. For example, we might add the statement:

Bartley Green is a Metropolitan District Ward

which translates to:

subjectpredicateobject
Bartley Green a Metropolitan District Ward
http://statistics.data.gov.uk/id/local-authority-ward/00CNGU http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://data.ordnancesurvey.co.uk/ontology/admingeo/MetropolitanDistrictWard

A collection of statements about things is called a graph.

Representing RDF

There are several different ways in which RDF can be serialised within a file such that RDF-aware processors can construct a graph from a document.

Turtle

Turtle is a plain-text-based syntax for representing RDF that is designed to be human-readable. Some example Turtle for the three RDF statements discussed above would be:

@prefix school : <http://education.data.gov.uk/def/school/>
@prefix admingeo : <http://data.ordnancesurvey.co.uk/ontology/admingeo/>

<http://education.data.gov.uk/id/school/103335>
  school:administrativeWard <http://statistics.data.gov.uk/id/local-authority-ward/00CNGU> ;
  school:FSMPercentage 47 .

<http://statistics.data.gov.uk/id/local-authority-ward/00CNGU>
  a admingeo:MetropolitanDistrictWard .

RDF/JSON

RDF/JSON is a way of representing RDF within JSON. The three statements above would be represented as:

{
  "http://education.data.gov.uk/id/school/103335" : {
    "http://education.data.gov.uk/def/school/administrativeWard" : [{
      "value" : "http://statistics.data.gov.uk/id/local-authority-ward/00CNGU" ,
      "type" : "uri"
    }] ,
    "http://education.data.gov.uk/def/school/FSMPercentage" : [{
      "value" : "47" ,
      "type" : "literal" ,
      "datatype" : "http://www.w3.org/1999/XMLSchema#integer"
    }]
  } ,
  "http://statistics.data.gov.uk/id/local-authority-ward/00CNGU" : {
    "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" : [{
      "value" : "http://data.ordnancesurvey.co.uk/ontology/admingeo/MetropolitanDistrictWard" ,
      "type" : "uri"
    }]
  }
}

RDF/XML

RDF/XML is the original syntax for RDF, and is still the one that is recognised by most RDF tools. Some RDF/XML for this data would look like:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:school="http://education.data.gov.uk/def/school/"
  xmlns:admingeo="http://data.ordnancesurvey.co.uk/ontology/admingeo/">
  
<rdf:Description rdf:about="http://education.data.gov.uk/id/school/103335">
  <school:administrativeWard rdf:resource="http://statistics.data.gov.uk/id/local-authority-ward/00CNGU" />
  <school:FSMPercentage rdf:datatype="http://www.w3.org/1999/XMLSchema#integer">47</school:FSMPercentage>
</rdf:Description>

<rdf:Description rdf:resource="http://statistics.data.gov.uk/id/local-authority-ward/00CNGU">
  <rdf:type rdf:resource="http://data.ordnancesurvey.co.uk/ontology/admingeo/MetropolitanDistrictWard" />
</rdf:Description>
  
</rdf:RDF>

RDFa

RDFa is unlike the other formats described here in that it is used to add information to normal web pages such that tools can extract an RDF graph from them. For example, a page might contain:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
  "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:school="http://education.data.gov.uk/def/school/"
  xmlns:admingeo="http://data.ordnancesurvey.co.uk/ontology/admingeo/">
  <head profile="http://www.w3.org/1999/xhtml/vocab">
    ...
  </head>
  <body about="http://education.data.gov.uk/id/school/103335">
    <h1>Nonsuch Primary School</h1>
    <p>
      Nonsuch Primary School is <span rel="school:administrativeWard">located in 
      <span about="http://statistics.data.gov.uk/id/local-authority-ward/00CNGU" 
        typeof="admingeo:MetropolitanDistrictWard">Bartley Green</span></span>. 
      <span property="school:FSMPercentage" datatype="xsd:integer" content="47">Forty-seven percent 
        of children at the school have free school meals</span>.
    </p>
  </body>
</html>

See also


Further Resources

Retrieved from "http://data.gov.uk/wiki/RDF"
Powered by MediaWiki
  • This page was last modified on 8 February 2010, at 07:15.
  • This page has been accessed 1,599 times.