Resource Description Framework (RDF)

Before the lab

Introduction

Lab instructions

The lab is divided into sections. You should allow aprox. 10 minutes for each section. However, note that the tasks are increasingly difficult and latter sections may be more time-consuming than the former ones.

1 RDF model

  • RDF model is a directed graph built from Statements
  • Each Statement consists of: <subject>, <predicate> and <object>
    • Subject can be an URI or an empty node
    • Predicate can be an URI
    • Object can be an URI, an empty node or a literal
    1. In section „Check by Direct Input” set Display Result Options to: Triples and Graph and click Parse RDF. Analyze the RDF/XML code and the graphical representation.
    2. In section „Check by URI” paste the following URI: http://home.agh.edu.pl/~wta/foaf.rdf. Analyze the RDF/XML code and the graphical representation.

2 RDF document: basics

RDF document is an RDF graph (describing some objects) serialized into chosen representation/syntax. Here we will use the RDF/XML syntax for RDF.

Your task will be to create an RDF description of you multimedia library. It can contain CDs, DVDs, books etc. The documents created during this lab will be used in the subsequent labs.

a) Create a text document and save it as mylibrary.rdf.

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
   <!-- Body Code Omitted -->
</rdf:RDF>

NB: Note the http://www.w3.org/1999/02/22-rdf-syntax-ns# namespace used in the document.

b) Add statements: Add RDF statements about items in your multimedia library, e.g.:

<rdf:RDF
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
 
   <rdf:Description rdf:about="http://example.org/mylibrary#book-semwebprimer">
		<!-- Statement Code Omitted -->
   </rdf:Description>
   <rdf:Description rdf:about="http://example.org/mylibrary#cd-opeth_damnation">
		<!-- Statement Code Omitted -->
   </rdf:Description>
</rdf:RDF>

The rdf:Description tag means you're going to describe something (a subject) and giving it a unique ID: http://example.org/mylibrary#your-book-id.

c) Add predicates: define some properties of the items and fill in their values, e.g.:

<rdf:RDF
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns="http://example.org/mylibrary#">
   <rdf:Description rdf:about="http://example.org/mylibrary#book-semwebprimer">
     <author>Grigoris Antoniou</author>
     <author>Frank van Harmelen</author>
     <title>A Semantic Web Primer</title>
   </rdf:Description>
   <rdf:Description rdf:about="http://example.org/mylibrary#cd-opeth_damnation">
     <artist>Opeth</artist>
     <title>Damnation</title>
   </rdf:Description>
</rdf:RDF>

Define your namespace (see the 3. line).

3 RDF document: Containers and Collections

In RDF there are two ways to describe set or sequences of objects: Containters and Collections.

  1. According to the W3C Recommendation, „A container is a resource that contains things. The contained things are called members. The members of a container may be resources (including blank nodes) or literals. RDF defines three types of containers:
    • rdf:Bag
    • rdf:Seq
    • rdf:Alt
  2. Create a container called MyFavouriteBooks and fill it with the URIs of the books you like the most. (see here for hints and examples)
  3. While „a container only says that certain identified resources are members; it does not say that other members do not exist.” with a Collection we can describe groups containing only the specified members. „An RDF collection is a group of things represented as a list structure in the RDF graph.”
  4. In your RDF file describe a book/CD/DVD which has multiple authors or actors playing in it. Use the RDF Collection. For hint and examples see the recommendation.

4 RDF document: Datatypes

Add the references to XML Schema datatypes to chosen information in your RDF file, e.g.:

<rdf:Description rdf:about="http://example.org/mylibrary#book-semwebprimer">
  <author>Grigoris Antoniou</author>
  <author>Frank van Harmelen</author>
  <title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A Semantic Web Primer</title>
  <publicationDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2008-10-09</publicationDate>
</rdf:Description>

5 RDF Triples Validation and Visualization

  1. Validate your example on the page RDF Validator from w3.org and analyze generated graph. Correct the errors, if you made any.
  2. Open your file in RDF Gravity tool. Browse your multimedia library using different filters.

6 RDFSchema

RDF Schema allows to organize objects into classes, define simple taxonomies, as well as classes' domains and ranges.

  1. Define classes of items in you multimedia library, e.g.
<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xml:base="http://example.org/mylibrary#">
 
  <rdfs:Class rdf:ID="MultimediaItem" />
  <rdfs:Class rdf:ID="MusicCD">
    <rdfs:subClassOf rdf:resource="#MultimediaItem"/>
    <rdfs:label>Music Compact Discs class</rdfs:label>
    <rdfs:comment>Class of all the CDs in my library.</rdfs:comment>
  </rdfs:Class>
  <rdfs:Class rdf:ID="Book">
    <rdfs:subClassOf rdf:resource="#MultimediaItem"/>
  </rdfs:Class>
</rdf:RDF>

Add the rdf:type statements to your RDF file, e.g.:

<rdf:Description rdf:about="http://example.org/mylibrary#cd-opeth_damnation">
  <artist>Opeth</artist>
  <title>Damnation</title>
  <rdf:type rdf:resource="http://example.org/mylibrary#MusicCD"/>
</rdf:Description>

7 RDF/S vocabularies: Dublin Core

Semantic vocabularies are sets of predefined properties for describing some domains. Examples include:

  1. Modify your RDF/S file to use the properties from DublinCore vocabulary, e.g.:
<rdf:Description rdf:about="http://example.org/mylibrary#book-semwebprimer">
  <author>Grigoris Antoniou</author>
  <author>Frank van Harmelen</author>
  <dc:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A Semantic Web Primer</dc:title>
  <dc:date rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2008-10-09</dc:date>
  <dc:publisher>The MIT Press</dc:publisher>
  <dc:language>en</dc:language>
</rdf:Description>  

8 RDF/S vocabularies: FOAF

FOAF (Friend-of-a-friend) is a semantic vocabulary for describing people and their connections.

  1. Create your FOAF file with: foaf-o-matic.
  2. Save you FOAF file.
  3. Put the file on a server (e.g. student.agh.edu.pl) so that it can be referenced with URL.
  4. Put the link to your FOAF file here (log in with username piw2011, for password ask the teacher):
  5. Visualize it with: FOAF explorer
  6. Add more friends using their FOAF URIs in the <foaf:knows> section. Visualize again. Navigate to your friends' FOAF files.

Control questions

  • What are:
    • resources,
    • properties,
    • statemets.
  • What does RDF use to identify resources?
  • What are the required elements of RDF file?
  • What are namespaces, how are they defined and what are they used for?
  • What the following tags are used for:
    • <rdf:Description>
    • <rdf:about>
    • <rdf:resource>
    • <rdf:type>
  • What container elements are available in RDF?
  • What is RDF Schema?
  • What are core RDFS Classes and properties?
  • How constraints on domain and range of properties are added?

If you want to know more

pl/dydaktyka/semweb/lab-rdf1.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0