CSA 3210 RDF & RDFS © 2
Exercises: Header Definition
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE rdf:RDF [
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#"> <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#"> <!ENTITY books "http://www.booksonline.com/books#"> <!ENTITY authors “http://www.cs.um.edu.mt/authors#> <!ENTITY base “http://www.cs.um.edu.mt/library/>
]> <rdf:RDF
xmlns:rdf=“&rdf;” xmlns:rdfs=“&rdfs;” xmlns:xsd=“&xsd; xmlns:books=“&books;” xmlns:authors=“&authors;” xmlns:base=“&base;”>
CSA 3210 RDF & RDFS © 3
RDF/XML Definitions/Graph View
n The library is located in Bremen <rdf:Description rdf:about=“library”> <books:libraryLoc rdf:datatype=“&xsd;string”>Bremen</books:libraryLoc> </rdf:Description>
CSA 3210 RDF & RDFS © 4
Graph View n The book with title “Artificial Intelligence” and ISBN 978-123458 is written by the author Henry Wise
CSA 3210 RDF & RDFS © 5
RDF/XML Definitions II n The book with title “Artificial Intelligence” and ISBN
978-123458 is written by the author Henry Wise <rdf:Description rdf:about="book012"> <rdf:type rdf:resource="&books;Book"/> <books:title rdf:datatype="&xsd;string">Artificial Intelligence </books:title> <books:isbn rdf:datatype="&xsd;string">ISBN 978123478</books:isbn> <books:author rdf:resource="#author12"/> </rdf:Description> <rdf:Description rdf:about="author12"> <books:authorName rdf:datatype="&xsd;string">HenryWise </books:authorName> </rdf:Description>
CSA 3210 RDF & RDFS © 6
Graph View n The author William Start wrote the books with titles “Modern Web Services” and “Theory of Computation”
CSA 3210 RDF & RDFS © 7
RDF/XML Definition
n The author William Start wrote the books with titles “Modern Web Services” and “Theory of Computation”
<rdf:Description rdf:about="author13"> <rdf:type rdf:resource="&books;author"/> <books:authorName rdf:datatype="&xsd;string">William Start
</books:authorName> <books:authorOf rdf:parseType="Collection"> <rdf:Description rdf:about="#book103"/> <rdf:Description rdf:about="#book102"/> </books:authorOf>
</rdf:Description>
CSA 3210 RDF & RDFS © 8
Moving up the layers
CSA 3210 RDF & RDFS © 9
RDF Schema
n Consider the following XML <author>Dan Brown</author> <journalist>John News</journalist> <magazine title=“Internet Computing”> <contributor>John Davies </contributor>
</magazine>
n Use XPath to collect all authors: //author n Result: “Dan Brown” n Though XML is correct, it is semantically unsatisfactory
(result should contain also John News and John Davies) n Need to define something of this sort:
q Authors, journalists and contributors are all writers q Only writers can contribute to a magazine
CSA 3210 RDF & RDFS © 10
RDF Schema II
n RDF makes no assumptions about any specific domain, nor does it define the semantics of such a domain
n To define the terminology related to any domain a schema language such as RDF Schema can be used
n Relation between RDF and RDF Schema is not the same as that between XML and XML Schema q XML schema constraints the structure of XML documents q RDFS defines the vocabulary used within an RDF data model
n through RDFS its also possible to q specify the properties that can be applied to an object q specify the values that such properties can take q declare relationships between objects
CSA 3210 RDF & RDFS © 11
RDF Schema III
n The user can describe any particular domain using: q Classes and Properties: differentiate between individual objects
(or instances) and classes of object n author: Dan Brown and class of authors n restrict properties to apply to certain things
q Only authors can contribute to certain magazines i.e. restrict the domain of contributors to a magazine as ranging only over authors
q Class Hierarchies and Inheritance n Classes of authors, writers, journalists, reporters, editors etc
q authors, journalists and reporters are all writers (journalist is a subclass of writer)
q Property Hierarchies n E.g. the property “authorOf” is a subproperty of “contributesTo” n However the converse may not necessarily be always true
CSA 3210 RDF & RDFS © 12
Core Classes
n rdfs:Resource, the class of all resources n rdfs:Class, the class of all classes n rdfs:Literal, the class of all literals
(strings) n rdf:Property, the class of all properties. <rdfs:Class rdf:about=“Process”> <rdfs:comment>Represents the class of all processes</rdfs:comment>
</rdfs:Class>
CSA 3210 RDF & RDFS © 13
Core Properties n rdf:type, which relates a resource to its class
q The resource is declared to be an instance of that class n rdfs:subClassOf, which relates a class to one of its
superclasses q All instances of a class are instances of its superclass
n rdfs:subPropertyOf, relates a property to one of its superproperties <rdfs:Class rdf:ID=“SysProcess”> <rdfs:subClassOf rdf:resource=“#Process”/> </rdfs:Class> <rdf:Property rdf:ID=“authorOf”> <rdfs:subPropertyOf rdf:resource=“#contributeTo”/> <rdf:Property>
CSA 3210 RDF & RDFS © 14
Core Properties (2)
n rdfs:domain, which specifies the domain of a property P q The class of those resources that may appear as subjects in a triple
with predicate P q If the domain is not specified, then any resource can be the subject
n rdfs:range, which specifies the range of a property P q The class of those resources that may appear as values (of objects)
in a triple with predicate P <rdf:Property rdf:ID=“procName”> <rdfs:domain rdf:resource=“#Process”/> <rdfs:range rdf:range=“&xsd;string”/> </rdf:Property>
CSA 3210 RDF & RDFS © 15
Example Literal
Contributor
Writer
Editor
Bookhas_name
has_name
subClassOf
subClassOf
authorOfhas_editor
Author
subClassOf
Journalist
subClassOf
CSA 3210 RDF & RDFS © 16
RDFS Example <rdfs:Class rdf:ID=“Writer”/> <rdfs:Class rdf:ID=“Author"> <rdfs:comment>all authors that contribute to books</
rdfs:comment> <rdfs:subClassOf rdf:resource="#Writer"/> </rdfs:Class> <rdfs:Class rdf:ID=“Book"> <rdfs:comment>The class of books</rdfs:comment>
</rdfs:Class> <rdf:Property rdf:ID=“authorOf"> <rdfs:subPropertyOf rdf:resource="#contributeTo"/> <rdfs:domain rdf:resource=“#Writer”/> <rdfs:range rdf:resource=“#Book”/>
</rdf:Property>
CSA 3210 RDF & RDFS © 17
RDFS Example II
<rdfs:Class rdf:about="#Author"> <rdfs:subClassOf rdf:resource="#Writer"/>
</rdfs:Class>
<rdf:Property rdf:ID=“phone"> <rdfs:domain rdf:resource="#Writer"/> <rdfs:range rdf:resource=“&xsd;Literal"/>
</rdf:Property>
CSA 3210 RDF & RDFS © 18
Complete Example
CSA 3210 RDF & RDFS © 19
Instance Example
CSA 3210 RDF & RDFS © 20
Applications of RDF/S: FOAF
n FOAF (Friend of a Friend) n FOAF is a way of providing affiliation and other social
information about yourself n Also a way of describing a network of friends and
others we know, in such a way that automated processes such as web bots can find this information and incorporate it with other FOAF files
n The FOAF-a-matic is a web form and the submitted information is used to generate the RDF/XML for a specific FOAF file and add it to the FOAF network.
CSA 3210 RDF & RDFS © 21
Foaf Example <foaf:Person rdf:ID="jhendler"><foaf:mbox_sha1sum>0b62d4242736e64be6138547c79a811b3e82fd52</foaf:mbox_sha1sum><foaf:firstName>Jim</foaf:firstName><foaf:surname>Hendler</foaf:surname><foaf:name>Jim Hendler</foaf:name><foaf:title>Tetherless World Constellation Chair</foaf:title>
<foaf:homepage rdf:resource="http://trust.mindswap.org/cgi-bin/FilmTrust/foaf.cgi?user=jhendler"/><foaf:homepage rdf:resource="http://www.cs.umd.edu/~hendler"/><foaf:depiction rdf:resource="http://www.semanticgrid.org/q-iantbljim.jpg"/>
<foaf:workplaceHomepage rdf:resource="http://owl.mindswap.org"/><foaf:img rdf:resource="http://www.cs.umd.edu/~hendler/hendler.gif"/><foaf:depiction rdf:resource="http://www.cs.umd.edu/~hendler/hendler.gif"/><foaf:nick>jhendler</foaf:nick>
<foaf:knows><foaf:Person rdf:about="http://trust.mindswap.org/cgi-bin/FilmTrust/foaf.cgi?user=golbeck#golbeck"><rdfs:seeAlso rdf:resource="http://trust.mindswap.org/cgi-bin/FilmTrust/foaf.cgi?user=golbeck"/><foaf:nick>golbeck</foaf:nick>
</foaf:Person></foaf:knows>
<foaf:knows><foaf:Person rdf:about="http://trust.mindswap.org/cgi-bin/FilmTrust/foaf.cgi?user=finin#finin"><rdfs:seeAlso rdf:resource="http://trust.mindswap.org/cgi-bin/FilmTrust/foaf.cgi?user=finin"/><foaf:nick>finin</foaf:nick>
</foaf:Person></foaf:knows>
CSA 3210 RDF & RDFS © 22
Photos of People I Know
FOAF
<foaf:knows><foaf:Person rdf:about="http://www.JohnGrech.org/john#john"/>
</foaf:knows><foaf:knows>
<foaf:Person rdf:about="http://www.PeterBorg/pietru#pietru"/></foaf:knows>
JohnFOAF
PeterFOAF
PersonalisedView
Photosfrom friends'
websites
PEA
CSA 3210 RDF & RDFS © 23
Applications of RDF/S: RDFHomepage
n Creates personal homepages based on your RDF data. n Takes the information in Bibtex, FOAF files, etc. and
automatically creates an RDFHomepage. n The generated HTML code is very general, and allows
quick and easy page-redesigning using CSS. n RDFHomepage is written in PHP and uses the system
to generate PHP classes based on RDF class definitions
CSA 3210 RDF & RDFS © 24
RDFHomepage: Social Network Researchers
CSA 3210 RDF & RDFS © 25
RDF Tools
n RDF Store: stores RDF models in relational dbs (persistent storage) q Jena can be hooked with MySQL, PostgreSQL or Oracle db
n RDF validator: validates RDF and presents different views (triples and dg) of result
n RDF Editors: q Protégé: http://protege.stanford.edu/ q Oiled: http://oiled.man.ac.uk/ q SWOOP: http://www.mindswap.org/2004/SWOOP/
n RDF visualiser q RDF Viz (visualises graphs)
n Search for schemas: q SWOOGLE: http://swoogle.umbc.edu/
CSA 3210 RDF & RDFS © 26
Further Information
n Semantic Web Primer, Chapter 3 n RDF Primer, E. Miller
q http://www.w3.org/TR/rdf-primer/
n RDF tutorial examples q http://www.zvon.org/xxl/RDFTutorial/General/contents.html
n The Semantic Web: roles of XML and RDF, Stefan Decker, q http://www.ontoknowledge.org/oil/downl/IEEE00.pdf
n Jena RDF tutorial, q http://jena.sourceforge.net/documentation.html
CSA 3210 RDF & RDFS © 27
Exercise
n Create an RDFS vocabulary for this scenario n Create an instance file with an author that has
published 3 different publications. You can add relevant properties to the basic concepts
Publication
ArticleConference_
Paper Book
Copyrights Author
xsd:string
has_namehas_phone
subClassOfsubClassOf subClassOf
copyrightedBy publishes
xsd:string
copyRightYear
xsd:string
copyRightContent
xsd:string
ISBN
xsd:string
publisherName
xsd:string
xsd:string
has_title
CSA 3210 RDF & RDFS © 28
Next Lecture
n Introduction to Description Logics q basis for Semantic Web languages
n Ontologies q Definition q Building q Use
CSA 3210 RDF & RDFS © 29
Namespaces for shorter serialisation n Writing URIs results in very long lines. n For convenience we use a shorthand of writing triples. n The XML qualified name without angle brackets <> is
used as abbreviation for the full URI reference. n A QName contains a prefix that has been assigned to a
namespace URI, followed by a colon, and then a local name.
n The full URI is formed from the QName by appending the local name to the namespace URI assigned to the prefix.
n So, for example, if the QName prefix foo is assigned to the namespace URI http://example.org/somewhere/, then the QName foo:bar is shorthand for the URIref q http://example.org/somewhere/bar.
CSA 3210 RDF & RDFS © 30
Namespaces used
n prefix rdf:, namespace URI: http://www.w3.org/1999/02/22-rdf-syntax-ns#
n prefix books:, namespace URI: http://www.booksInfo.com/books#”
n prefix xsd:, namespace URI: http://www.w3.org/2001/XMLSchema#
n prefix authors:, namespace URI: http://www.authorsInfo.org/authors#”
n prefix base:, namespace URI: http://www.bookstore.com/books