====== Resource Description Framework (RDF) ====== ===== Before the lab ===== Reading: * [[http://w3schools.com/rdf/default.asp|RDF at W3Schools]] * [[http://dublincore.org/documents/dc-rdf/|Expressing Dublin Core metadata using the Resource Description Framework (RDF)]] * [[http://www.betaversion.org/~stefano/linotype/news/57/|A No-Nonsense Guide to Semantic Web Specs for XML People]] * [[#if_you_want_to_know_more|If you want to know more...]] Software: * [[http://semweb.salzburgresearch.at/apps/rdf-gravity|RDF Gravity]] ===== Introduction ===== Lecture: * {{http://home.agh.edu.pl/wta/semweb/geist-semweb-rdf.pdf|Semantic Web: 3a - RDF}} * {{http://home.agh.edu.pl/wta/semweb/geist-semweb-rdfsutils.pdf|Semantic Web: 3b - RDF/S in use}} * {{http://home.agh.edu.pl/wta/semweb/geist-semweb-rdfs.pdf|Semantic Web: 3c - RDF Schema}} ===== 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. ==== - RDF model ==== * RDF model is a directed graph built from ''Statements'' * Each Statement consists of: '''', '''' and '''' * 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// - Go to [[http://www.w3.org/RDF/Validator/|W3C's RDF Validation Service]] - 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. {{:pl:dydaktyka:semantic_web:rdf-validator1.png?200|}} - 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. {{:pl:dydaktyka:semantic_web:rdf-validator2.png?200|}} ==== - 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''. 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.: 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.: Grigoris Antoniou Frank van Harmelen A Semantic Web Primer Opeth Damnation Define your namespace (see the 3. line). ==== - RDF document: Containers and Collections ==== In RDF there are two ways to describe set or sequences of objects: //Containters// and //Collections//. - According to the [[http://www.w3.org/TR/rdf-syntax/#containers|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''" - Create a container called ''MyFavouriteBooks'' and fill it with the URIs of the books you like the most. (see [[http://www.w3.org/TR/rdf-syntax/#containers|here]] for hints and examples) - 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." - 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 [[http://www.w3.org/TR/rdf-syntax/#collections|recommendation]]. ==== - RDF document: Datatypes ==== Add the references to [[http://www.w3.org/TR/xmlschema-2/|XML Schema datatypes]] to chosen information in your RDF file, e.g.: Grigoris Antoniou Frank van Harmelen A Semantic Web Primer 2008-10-09 ==== - RDF Triples Validation and Visualization ==== - Validate your example on the page [[http://www.w3.org/RDF/Validator//| RDF Validator from w3.org]] and analyze generated graph. Correct the errors, if you made any. - Open your file in [[http://semweb.salzburgresearch.at/apps/rdf-gravity|RDF Gravity]] tool. Browse your multimedia library using different filters. ==== - RDFSchema ==== RDF Schema allows to organize objects into classes, define simple taxonomies, as well as classes' domains and ranges. - Define classes of items in you multimedia library, e.g. Music Compact Discs class Class of all the CDs in my library. Add the ''rdf:type'' statements to your RDF file, e.g.: Opeth Damnation ==== - RDF/S vocabularies: Dublin Core ==== Semantic vocabularies are sets of predefined properties for describing some domains. Examples include: * [[http://semanticweb.org/wiki/Dublin_Core|Dublin Core]] * [[http://semanticweb.org/wiki/FOAF|FOAF]] * [[http://semanticweb.org/wiki/RSS_1.0|RSS 1.0]] * [[http://semanticweb.org/wiki/SIOC|SIOC]] * etc. - Have a look at [[http://www.w3schools.com/rdf/rdf_dublin.asp|Dublin Core basics at W3Schools]]. - Modify your RDF/S file to use the properties from DublinCore vocabulary, e.g.: Grigoris Antoniou Frank van Harmelen A Semantic Web Primer 2008-10-09 The MIT Press en * Hint: use the explanation and examples from [[http://dublincore.org/documents/dcmes-xml/|the basic (superseeded) version of DC]] or, if you are more ambitious, read the latest, enhanced [[http://dublincore.org/documents/dc-rdf/|version]]. ==== - RDF/S vocabularies: FOAF ==== [[http://www.foaf-project.org/|FOAF]] (Friend-of-a-friend) is a semantic vocabulary for describing people and their connections. - Create your FOAF file with: [[http://www.ldodds.com/foaf/foaf-a-matic|foaf-o-matic]]. - Save you FOAF file. - Put the file on a server (e.g. ''student.agh.edu.pl'') so that it can be referenced with URL. - Put the link to your FOAF file [[#foaf_files_of_piw_2011|here]] (log in with username ''piw2011'', for password ask the teacher): - Visualize it with: [[http://xml.mfd-consult.dk/foaf/explorer/|FOAF explorer]] - Add more friends using their FOAF URIs in the '''' section. Visualize again. Navigate to your friends' FOAF files. * (example) Weronika T. Adrian: http://home.agh.edu.pl/~wta/foaf.rdf ===== 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: * '''' * '''' * '''' * '''' * 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 ===== Reading: * RDF Primer, W3C Recommendation 10-02-2004: http://www.w3.org/TR/rdf-primer/ * http://www.w3.org/DesignIssues/RDFnot.html * RDF interfaces, Working Draft 11-05-2011: http://www.w3.org/TR/rdf-interfaces/ Slides: * [[ http://www.inf.unibz.it/~debruijn/teaching/swt/lecture-1-handouts.pdf|RDF ]] and [[http://www.inf.unibz.it/~debruijn/teaching/swt/lecture-2-handouts.pdf|RDFS]] * [[http://www.cs.rpi.edu/~puninj/XMLJ/classes/class8/all.html| RDF and RDFS summary]] Tools: * http://jena.sourceforge.net/tutorial/RDF_API/