SlideShare una empresa de Scribd logo
1 de 44
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 1
Semantic Web
Unit 4: RDF and RDF Schema
Faculty of Science, Technology and Communication (FSTC)
Bachelor en informatique (professionnel)
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 2
4. RDF and RDF Schema
2
Semantic Web Roadmap:
Controlled growth bottom
up according to this
architecture.
Architecture was (slightly)
modified in the last years.
2
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 3
4. RDF and RDF Schema
4.1. Why is XML not Sufficient?
4.2. RDF Specifications
4.3. RDF Schema (RDFS)
4.4. SPARQL – RDF Query Language
4.5. Sharing Vocabulary in RDF
4.6. Jena – RDF in Java
4.7. References
33
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 4
4.1. Why is XML not Sufficient?
4. RDF and RDF Schema
Level of knowledge representation and semantics
XML / XML Schema
objects, structure
RDF / RDF Schema
knowledge about
objects, relations
between objects
OWL
domain knowledge,
interconnections
44
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 5
4.1. Why is XML not Sufficient?
4. RDF and RDF Schema
Problem 1: missing relational expressivity
What is the relation between a
"Professor", a "Secretary" and a
"PhDStudent"?
Christoph Meinel
Viola Brehmer
Long Wang
Feng Cheng
Dirk Cordel
Serge Linckels
Harald Sack
<ChairMeinel>
<Professor>
<FirstName>Christoph</FirstName>
<LastName>Meinel</LastName>
</Professor>
<Secretary>Viola Brehmer</Secretary>
<PhDStudent>Long Wang</PhDStudent>
<PhDStudent>Feng Cheng</PhDStudent>
<PhDStudent>Dirk Cordel</PhDStudent>
<PhDStudent>Serge Linckels</PhDStudent>
<FormerPhDStudent>Harald Sack</FormerPhDStudent>
</ChairMeinel>
XML document
We need a more powerful formalism above XML to
describe relations between objects
55
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 6
4.1. Why is XML not Sufficient?
4. RDF and RDF Schema
Problem 2: missing relational expressivity
Are all three documents
equivalent?
Do they represent the
same information?
<phonenumber>
<owner>Serge Linckels</owner>
<number>++352-691-123456</number>
</phonenumber>
XML document 1
We need a more powerful formalism above XML to
describe objects with a shared vocabulary
<person>
<name>Serge Linckels</name>
<phone>++352-691-123456</phone>
</person>
XML document 2
<person name="Serge Linckels" phone="++352-691-123456" />
XML document 3
Solving this kind of problem requires a
matching of all 3 documents and their
according DTD / XML Schema, e.g., with
XSLT. This reengineering is difficult,
complex and can be avoided.
66
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 7
4.2. RDF Specifications
4. RDF and RDF Schema
RDF overview
Resource Description Framework
RDF allows to describe resources in
a more expressive way than XML
RDF can be serialized as XML (or in
other formats)
The syntax of a RDF document can
be described in a RDF Schema
RDF documents can be queried
using optimized query languages,
e.g., SPARQL
77
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 8
RDF
English
4.2. RDF Specifications
4. RDF and RDF Schema
RDF standard
W3C recommendation
Make statements (assertions) about resources, e.g.,
"Serge Linckels is a teacher. He teaches RDF."
The object "Serge Linckels" has a property "hasJob" that has
the value "teacher"
The object "Serge Linckels" has a property "toTeach" that has
the value "RDF"
Statement 1
Statement 2
RDF statement
A RDF statement is a "triple": resource – property – value
teacherSerge Linckels
hasJob
Subject Predicate Object
Resource Property Value
88
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 9
4.2. RDF Specifications
4. RDF and RDF Schema
RDF graph
RDF statements are represented as directed and labeled graphs, where each resource is
represented as a node
Each resource is identified by a URI
teacher
hasJob
RDF
toTeach
RDF graphs can be serialized in different formats, e.g., as XML
RDF serialization
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:myNS="http://www.linckels.lu/myNS/">
<rdf:Description rdf:about="http://www.linckels.lu/">
<myNS:hasJob>teacher</myNS:hasJob>
<myNS:toTeach>RDF</myNS:toTeach>
</rdf:Description>
</rdf:RDF>
http://www.linckels.lu/
99
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 10
4.2. RDF Specifications
4. RDF and RDF Schema
RDF validation
RDF graphs can be validated with "a
validator", e.g.,
http://www.w3.org/RDF/Validator/
1010
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 11
4.2. RDF Specifications
4. RDF and RDF Schema
More about objects
An RDF object can be a literal
teacherSerge Linckels
hasJob
is a literal
An RDF object can be a resource
Serge Linckels
worksWith
is a resource
Denis Zampuniéris
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:myNS="http://www.linckels.lu/myNS/">
<rdf:Description rdf:about="http://www.linckels.lu/">
<myNS:hasJob>teacher</myNS:hasJob>
<myNS:worksWith rdf:resource="http://www.zampunieris.be" />
</rdf:Description>
</rdf:RDF>
1111
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 12
4.2. RDF Specifications
4. RDF and RDF Schema
Example – RDF graph
teacher
RDF
toTeach
Les Générations Pascal
professor
Serge Linckels
Denis Zampuniéris
hasName
hasJob
hasName
hasJob
hasTitle
http://www.zampunieris.be
http://www.linckels.lu/
ISBN: 2-495-10604-8
1212
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 13
4.2. RDF Specifications
4. RDF and RDF Schema
Example – XML serialization
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:myNS="http://www.linckels.lu/myNS/">
<rdf:Description rdf:about="http://www.linckels.lu/">
<myNS:hasJob>teacher</myNS:hasJob>
<myNS:hasName>Serge Linckels</myNS:hasName>
<myNS:toTeach>RDF</myNS:toTeach>
<myNS:worksWith rdf:resource="http://www.zampunieris.be/" />
</rdf:Description>
<rdf:Description rdf:about="http://www.zampunieris.be/">
<myNS:hasJob>professor</myNS:hasJob>
<myNS:hasName>Denis Zampunieris</myNS:hasName>
<myNS:likesToRead rdf:resource="ISBN: 2-495-10604-8" />
</rdf:Description>
<rdf:Description rdf:about="ISBN: 2-495-10604-8">
<myNS:hasTitle>Les Générations Pascal</myNS:hasTitle>
<myNS:hasAuthor rdf:resource="http://www.linckels.lu/" />
</rdf:Description>
</rdf:RDF>
Related elements
must not be nested
within the elements
they are related to
1313
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 14
4.2. RDF Specifications
4. RDF and RDF Schema
RDF directed graph – 3 types of nodes
teacher
hasJob
http://www.linckels.lu/
Serge
first
Linckels
last
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:myNS="http://www.linckels.lu/myNS/">
<rdf:Description rdf:about="http://www.linckels.lu/">
<myNS:fullname>
<rdf:Description>
<myNS:first>Serge</myNS:first>
<myNS:last>Linckels</myNS:last>
</rdf:Description>
</myNS:fullname>
<myNS:hasJob>teacher</myNS:hasJob>
</rdf:Description>
</rdf:RDF>
uriref node
blank node
literal
1414
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 15
4.2. RDF Specifications
4. RDF and RDF Schema
RDF type attribute
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:myNS="http://www.linckels.lu/myNS/">
<rdf:Description rdf:about="http://www.linckels.lu/">
<myNS:hasName>Serge Linckels</myNS:hasName>
<myNS:hasJob>teacher</myNS:hasJob>
<rdf:type rdf:resource="http://www.linckels.lu/myNS/Person" />
</rdf:Description>
</rdf:RDF>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:myNS="http://www.linckels.lu/myNS/">
<myNS:Person rdf:about="http://www.linckels.lu/">
<myNS:hasName>Serge Linckels</myNS:hasName>
<myNS:hasJob>teacher</myNS:hasJob>
</myNS:Person>
</rdf:RDF>
rdf:type explicitly specifies the type of a resource
The following two examples are equivalent
1515
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 16
4.2. RDF Specifications
4. RDF and RDF Schema
RDF datatypes
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:myNS="http://www.linckels.lu/myNS/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
<myNS:Person rdf:about="http://www.linckels.lu/">
<myNS:hasName rdf:datatype="xsd:string">Serge Linckels</myNS:hasName>
<myNS:luckyNumber rdf:datatype="xsd:integer">12</myNS:luckyNumber>
</myNS:Person>
</rdf:RDF>
rdf:datatype explicitly specifies the type of a literal
No implicit semantics are attached to typed literals
1616
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 17
rdf:Bag
4.2. RDF Specifications
4. RDF and RDF Schema
RDF containers - example
Serge Linckels
http://www.linckels.lu/
Aviation
_1
Krav Maga
_2
hasName
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:myNS="http://www.linckels.lu/myNS/">
<rdf:Description rdf:about="http://www.linckels.lu/">
<myNS:hasHobbies>
<rdf:Bag>
<rdf:li>Aviation</rdf:li>
<rdf:li>Krav Maga</rdf:li>
</rdf:Bag>
</myNS:hasHobbies>
<myNS:hasName>Serge Linckels</myNS:hasName>
</rdf:Description>
</rdf:RDF>
1717
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 18
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 19
4.2. RDF Specifications
4. RDF and RDF Schema
RDF containers - overview
rdf:Bag – containing unordered lists of resources or literals, with duplicate data allowed
rdf:Seq – containing ordered lists of resources or literals, with duplicate data allowed
rdf:Alt – containing resources or literals that represent possible alternatives for a specific
value
RDF collections - overview
Unlike a container, a collection is a finite grouping of resources or literals
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:myNS="http://www.linckels.lu/myNS/">
<rdf:Description rdf:about="http://www.linckels.lu/">
<myNS:hasFriends rdf:parseType="Collection">
<rdf:Description rdf:about="http://www.toto.lu" />
<rdf:Description rdf:about="http://www.titi.lu" />
<rdf:Description rdf:about="http://www.tata.lu" />
</myNS:hasFriends>
<myNS:hasName>Serge Linckels</myNS:hasName>
</rdf:Description>
</rdf:RDF>
1919
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 20
rdf:list
4.2. RDF Specifications
4. RDF and RDF Schema
RDF lists
Serge Linckels
http://www.linckels.lu/
hasName
http://www.toto.lu/
rdf:first
http://www.titi.lu/
rdf:first
rdf:rest
http://www.tata.lu/
rdf:first
rdf:rest
rdf:nil
rdf:rest
A list is a terminated sequence of
items
Traversing a list becomes a
matter of finding the start node
and then accessing the next
predicates for that node
2020
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 21
4.2. RDF Specifications
4. RDF and RDF Schema
RDF lists
21
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:myNS="http://www.linckels.lu/myNS/">
<rdf:Description rdf:about="http://www.linckels.lu/">
<myNS:hasFriends>
<rdf:List>
<rdf:first rdf:resource="http://www.toto.lu" />
<rdf:rest>
<rdf:List>
<rdf:first rdf:resource="http://www.titi.lu" />
<rdf:rest
rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
</rdf:List>
</rdf:rest>
</rdf:List>
</myNS:hasFriends>
<myNS:hasName>Serge Linckels</myNS:hasName>
</rdf:Description>
</rdf:RDF>
21
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 22
rdf:Statement
4.2. RDF Specifications
4. RDF and RDF Schema
Reification
Reification is a method of formally
modeling a statement about another
statement
sweetThis lemon
are
Serge Linckels
says
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:myNS="http://www.linckels.lu/myNS/">
<rdf:Description rdf:about="http://www.linckels.lu/">
<myNS:says rdf:resource="#myStatement" />
</rdf:Description>
<rdf:Statement rdf:about="#myStatement">
<rdf:subject rdf:resource="http://www.lemon123.lu" />
<rdf:predicate rdf:resource="myNS:are" />
<rdf:object>sweet</rdf:object>
</rdf:Statement>
</rdf:RDF>
identification of
the statement
2222
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 23
4.2. RDF Specifications
4. RDF and RDF Schema
rdf:Statement
Reification – problem
Reification is always an subjective view and can cause ambiguities
sweetThis lemon
are
Serge Linckels
says
rdf:Statement
bitter
are
DenisZampunieris
says
Who do you believe?
2323
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 24
4.2. RDF Specifications
4. RDF and RDF Schema
Reification is useful
Useful to formally express trust
1.61803
π hasValue
Serge Linckels
says
3.14159
hasValue
Who do you believe?
A. Einstein
D. Zampunieris
M. Planck
O. Hahn
says
says
Create metadata over assertions (assertion ≠ fact)
2424
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 25
Database 1
Database 2
4.2. RDF Specifications
4. RDF and RDF Schema
RDF helps to make semantic relations between databases
Les Générations
Pascal
hasAuthor
http://www.linckels.lu/
ISBN: 2-495-10604-8
http://www.men.lu
publishedBy
http://www.myschool.lu
http://www.men.lu
hasProject
Ministère de
l'Éducation
Nationale
hasName
Relations between distinct databases can made explicit  same URI = same resources
Data can be integrated (from one database into another)  same URI, same vocabulary
2525
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 26
4.2. RDF Specifications
4. RDF and RDF Schema
RDF helps to make semantic relations between databases
Relations between distinct databases can made explicit  same URI = same resources
Data can be integrated (from one database into another)  same URI, same vocabulary
26
Les Générations
Pascal
hasAuthor
http://www.linckels.lu/
ISBN: 2-495-10604-8
publishedBy
hasTitle
http://www.myschool.lu
http://www.men.lu
hasProject
Ministère de
l'Éducation
Nationale
hasName
26
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 27
4.3. RDF Schema (RDFS)
4. RDF and RDF Schema
RDFS overview
RDFS specifies:
- how RDF constructs relate to each other
- how RDF constructs can be diagrammed in XML
RDFS is a rules-based dictionary that:
- defines the elements of importance to a domain
- describes how these elements relate to one another
RDF is a way of describing data
RDFS is a domain-neutral way of describing the metadata that can be used to
describe the data for domain-specific vocabulary
RDFS allows to define:
- abstract datatypes (classes)
- hierarchically structure the datamodel
- properties and relations (e.g., inheritance)
2727
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 28
4.3. RDF Schema (RDFS)
4. RDF and RDF Schema
RDFS – defining classes
rdfs:Resource is the RDFS top-class
rdfs:Resource
myNS:Person
fullname
Example:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<rdfs:class rdf:about="http://www.linckels.lu/myNS/Person">
<rdfs:subClassOf
rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Resource" />
</rdfs:class>
<rdf:Property rdf:about="http://www.linckels.lu/myNS/fullname">
<rdfs:domain rdf:resource="http://www.linckels.lu/myNS/Person" />
</rdf:Property>
</rdf:RDF>
rdfs:class – definition of a new class that inherits from the super class
specified in rdfs:subClassOf
rdf:Property – definition of a new property of a class specified in
rdfs:domain
2828
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 29
4.3. RDF Schema (RDFS)
4. RDF and RDF Schema
RDFS – defining a instance of a class
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:myNS="http://www.linckels.lu/myNS/">
<rdfs:class rdf:about="http://www.linckels.lu/myNS/Person">
<rdfs:subClassOf
rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Resource" />
</rdfs:class>
<rdf:Property rdf:about="http://www.linckels.lu/myNS/fullname">
<rdfs:domain rdf:resource="http://www.linckels.lu/myNS/Person" />
</rdf:Property>
<myNS:Person rdf:about="http://www.linckels.lu/">
<myNS:fullname>Serge Linckels</myNS:fullname>
</myNS:Person>
</rdf:RDF>
<rdf:Description rdf:about="http://www.linckels.lu/">
<myNS:fullname>Serge Linckels</myNS:fullname>
<rdf:type rdf:resource="http://www.linckels.lu/myNS/Person" />
</rdf:Description>
=
2929
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 30
4.3. RDF Schema (RDFS)
4. RDF and RDF Schema
RDFS – defining relations and restrictions rdfs:Resource
myNS:Person
worksFor
age
<rdf:Property rdf:about="http://www.linckels.lu/myNS/worksFor">
<rdfs:domain rdf:resource="http://www.linckels.lu/myNS/Person" />
<rdfs:range rdf:resource="http://www.linckels.lu/myNS/Firm" />
</rdf:Property>
myNS:Firm
rdfs:range – specifies the classes the property can
reference as values
<rdf:Property rdf:about="http://www.linckels.lu/myNS/age">
<rdfs:domain rdf:resource="http://www.linckels.lu/myNS/Person" />
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer" />
</rdf:Property>
This mechanism allows to define basic relations between
classes and to define datatypes for property values
A validator checks only the syntax, not if
the values for properties are correct. This
task must be assumed by the application.
!
3030
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 31
4.3. RDF Schema (RDFS)
4. RDF and RDF Schema
RDFS – other elements
rdfs:label – provides a (human) readable version the resource's name
rdfs:Literal - defines a node as being a literal value, not a resource
rdfs:Comment – defines a comment
rdfs:Container – superclass of all RDF container elements (rdf:Bag, rdf:Seq and rdf:Alt)
rdfs:member – superproperty for each numbered container element (e.g., _1, _2, etc.)
rdfs:subPropertyOf – specifies a property as a refinement of another property
rdfs:seeAlso – identifies another resource that contains additional information
rdfs:isDefinedBy – identifies the namespace for the resource, preventing any ambiguity
3131
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 32
4.4. SPARQL – RDF Query Language
4. RDF and RDF Schema
RDF query languages – overview
There exists multiple languages to query RDF data: ARQ, RDQL, N3QL, RQL, SPARQL, SeRQL,
Versa, XUL, Adenine, RDQ, N3QL…
SPARQL (SPARQL Protocol and RDF Query Language) was standardized in January 2008 by the
W3C
"SQL like" syntax to query RDF data as triples
@prefix myNS: <http://www.linckels.lu/myNS#>
SELECT DISTINCT ?X
FROM <http://www.linckels.lu/myRDF-file.rdf>
WHERE
{
myNS:Person myNS:worksFor ?X .
}
Example: "show me all firms that have employees"
Complex filtering is possible, e.g.,
- string operations
- conjunctions and disjunctions of logical tests
- datatype checking
32
triple
32
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 33
4.4. SPARQL – RDF Query Language
4. RDF and RDF Schema
RDF query languages – overview
@prefix myNS: <http://www.linckels.lu/myNS#>
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?person ?firm
FROM <http://www.linckels.lu/myRDF-file.rdf>
WHERE
{
?person rdf:type myNS:Person .
?person myNS:worksFor ?firm .
?firm rdf:type myNS:Firm .
?person myNS:age ?age .
FILTER (?age > 30) .
FILTER (?age <= 40) .
}
Example: "show me all persons and the firms they work for, who are between 31 and 40 in
age"
3333
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 34
4.5. Sharing Vocabulary in RDF
4. RDF and RDF Schema
Problem with not identical predicates
Les Générations Pascal
hasTitle
ISBN: 2-495-10604-8
Les Générations Pascal
avoirTitre
ISBN: 2-495-10604-8
= ?
- Resources are equal because same URI
- Objects are equal because same value
 are both predicates equal ?
Use (as far as possible) existing vocabulary for predicates, or share your own
vocabulary with others
Examples: Dublin Core (DC), Friend of a Friend (FOAF)
3434
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 35
4.5. Sharing Vocabulary in RDF
4. RDF and RDF Schema
Dublin Core (DC)
Les Générations Pascal
dc:title
ISBN: 2-495-10604-8
DC metadata element set is a standard for cross-domain information resource description
Provides a simple and standardized set of conventions for describing resources
DC is widely used to describe digital materials such as video, sound, image, text, and
composite media like web pages
Dublin Core is defined by NISO Standard Z39.85-2007
http://dublincore.org/
DC is controlled by Dublin Core Metadata Initiative (DCMI), an organization providing an open
forum for the development of interoperable online metadata standards
3535
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 36
4.5. Sharing Vocabulary in RDF
4. RDF and RDF Schema
Dublin Core (DC)
Simple Dublin Core Metadata Element Set (DCMES) consists of 15 metadata elements
Qualified Dublin Core Metadata Element Set (QDCME) includes three additional elements
(audience, provenance and rightsholder), as well as a group of element refinements
title : a name given to a resource
creator : an entity responsible for making the content of the resource
subject : the topic of the content of the resource
description : an account of the content of the resource
publisher : an entity responsible for making the content available
contributor : an entity responsible for making contributions to the content of the resource
date : a date associated with an event in the life cycle of the resource
type : the nature or genre of the content of the resource
format : the physical or digital manifestation of the resource
identifier : an unambiguous reference to the resource within a given context
source : a reference to the resource from which the present resource is derived
language : a language of the intellectual content of the resource
relation : a reference to a related resource
coverage : the extent or scope of the content of the resource
rights : information about rights held in and over the resource
3636
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 37
FOAF Basics
Personal Info
Online Accounts
Projects & Groups
Documents & Images
4.5. Sharing Vocabulary in RDF
4. RDF and RDF Schema
Friend of a Friend (FOAF)
FOAF is a way to describe people and relationships to computers; it is a vocabulary
http://www.foaf-project.org/
Agent
Person
name
nick
title
homepage
mbox
mbox_sha1sum
img
depiction
surname
family_name
givenname
firstName
weblog
knows
interest
currentProject
pastProject
plan
based_near
workplaceHomepage
workInfoHomepage
schoolHomepage
topic_interest
publications
geekcode
myersBriggs
dnaChecksum
OnlineAccount
OnlineChatAccount
OnlineEcommerceAccount
OnlineGamingAccount
holdsAccount
accountServiceHomepage
accountName
icqChatID
msnChatID
aimChatID
jabberID
yahooChatID
Project
Organization
Group
member
membershipClass
fundedBy
theme
Document
Image
PersonalProfileDocument
topic (page)
primaryTopic
tipjar
sha1
made (maker)
thumbnail
logo
3737
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 38
4.5. Sharing Vocabulary in RDF
4. RDF and RDF Schema
Mixing Vocabularies
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:myNS="http://www.linckels.lu/myNS/">
<myNS:Person rdf:about="http://www.linckels.lu/">
<foaf:name>Serge Linckels</foaf:name>
<myNS:toTeach>RDF</myNS:toTeach>
</myNS:Person>
<rdf:Description rdf:about="ISBN: 2-495-10604-8">
<dc:title>Les Générations Pascal</dc:title>
<dc:creator rdf:resource="http://www.linckels.lu/" />
</rdf:Description>
</rdf:RDF>
38
RDF
myNS:toTeach
Les Générations Pascal
Serge Linckels
dc:title
dc:creator
http://www.linckels.lu/
ISBN: 2-495-10604-8
38
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 39
4.6. Jena – RDF in Java
4. RDF and RDF Schema
Jena – overview
Jena is a Java framework for building Semantic Web applications
Jena provides a programmatic environment for RDF, RDFS, OWL and SPARQL
Jena is open source and grown out of work with the HP Labs Semantic Web Programme
http://jena.sourceforge.net/
3939
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 40
4.6. Jena – RDF in Java
4. RDF and RDF Schema
Jena – example: creating a resource
import com.hp.hpl.jena.mem.ModelMem;
import com.hp.hpl.jena.rdf.model.*;
static String myDemo= "http://www.linckels.lu/";
static String myNS = " http://www.linckels.lu/myNS";
// create an empty graph
Model myModel = new ModelMem();
// create the resource
Resource myResource = myModel.createResource(myDemo);
// create the predicate (property)
Property fullname = myModel.createProperty(myNS,"fullname");
// add the property with associated value (object)
myResource.addProperty(fullname, "Serge Linckels");
// print RDF/XML of model to system out
myModel.write(new PrintWriter(System.out));
4040
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 41
4.6. Jena – RDF in Java
4. RDF and RDF Schema
Jena – example: browsing through a graph
// using a statement iterator
StmtIterator iter = myModel.listStatements();
while (iter.hasNext()) {
// read a statement (resource, predicate, object)
Statement stmt = iter.next();
// identify resource
Resource subject = stmt.getSubject();
// identify predicate
Property predicate = stmt.getPredicate();
// identify object
RDFNode object = stmt.getObject();
// output
System.out.print("("+predicate.toString()+",");
System.out.print(subject.toString()+",");
System.out.println(object.toString()+")");
}
4141
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 42
4.6. Jena – RDF in Java
4. RDF and RDF Schema
Jena – example: read and write a file
String filename = "myFile.rdf";
// creating a model
Model myModel = new ModelMem();
// read a file
Model.read(new FileReader(filename));
// write a file
Model.write(new PrintWriter(System.out));
Jena – example: creating a container
Bag bag = myModel.createBag();
bag.add("Romeo and Juliet")
bag.add("Hamlet")
bag.add("Othello");
NodeIterator iter = bag.iterator();
while (iter.hasNext()) {
System.out.println(" " + iter.next().toString());
}
4242
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 43
Creating the Semantic Web with RDF: Professional Developer's Guide
Johan Hjelm
4.7. References
4. RDF and RDF Schema
Practical RDF
Shelley Powers
4343
E-Librarian Service
User-Friendly Semantic Search in Digital Libraries
Serge Linckels, Christoph Meinel
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 44
A Semantic Web Primer (Cooperative Information Systems)
Grigoris Antoniou , Frank van Harmelen
Semantic Web: Concepts, Technologies and Applications
K.K. Breitman, M.A. Casanova, W. Truszkowski
4.7. References
4. RDF and RDF Schema
44
Foundations of Semantic Web Technologies
Pascal Hitzler, Markus Krötzsch, Sebastian Rudolph
44

Más contenido relacionado

Similar a Semantic Web - RDF

Publishing Linked Data 3/5 Semtech2011
Publishing Linked Data 3/5 Semtech2011Publishing Linked Data 3/5 Semtech2011
Publishing Linked Data 3/5 Semtech2011
Juan Sequeda
 
Chicago LOMRDF update 2003-06-19
Chicago LOMRDF update 2003-06-19 Chicago LOMRDF update 2003-06-19
Chicago LOMRDF update 2003-06-19
Mikael Nilsson
 

Similar a Semantic Web - RDF (20)

A Hands On Overview Of The Semantic Web
A Hands On Overview Of The Semantic WebA Hands On Overview Of The Semantic Web
A Hands On Overview Of The Semantic Web
 
Technical Background
Technical BackgroundTechnical Background
Technical Background
 
semantic web resource description framework
semantic web resource description frameworksemantic web resource description framework
semantic web resource description framework
 
Tutorial for RDF Graphs
Tutorial for RDF GraphsTutorial for RDF Graphs
Tutorial for RDF Graphs
 
The Semantic Web #5 - RDF (2)
The Semantic Web #5 - RDF (2)The Semantic Web #5 - RDF (2)
The Semantic Web #5 - RDF (2)
 
RDF Data Model
RDF Data ModelRDF Data Model
RDF Data Model
 
The Semantic Web #9 - Web Ontology Language (OWL)
The Semantic Web #9 - Web Ontology Language (OWL)The Semantic Web #9 - Web Ontology Language (OWL)
The Semantic Web #9 - Web Ontology Language (OWL)
 
RDF(S) and SPARQL
RDF(S) and SPARQLRDF(S) and SPARQL
RDF(S) and SPARQL
 
Semantic web application architecture
Semantic web   application architectureSemantic web   application architecture
Semantic web application architecture
 
Data in RDF
Data in RDFData in RDF
Data in RDF
 
Rdf Overview Presentation
Rdf Overview PresentationRdf Overview Presentation
Rdf Overview Presentation
 
Semantic Web - OWL
Semantic Web - OWLSemantic Web - OWL
Semantic Web - OWL
 
SemWeb Fundamentals - Info Linking & Layering in Practice
SemWeb Fundamentals - Info Linking & Layering in PracticeSemWeb Fundamentals - Info Linking & Layering in Practice
SemWeb Fundamentals - Info Linking & Layering in Practice
 
06 gioca-ontologies
06 gioca-ontologies06 gioca-ontologies
06 gioca-ontologies
 
Graph databases & data integration v2
Graph databases & data integration v2Graph databases & data integration v2
Graph databases & data integration v2
 
Publishing Linked Data 3/5 Semtech2011
Publishing Linked Data 3/5 Semtech2011Publishing Linked Data 3/5 Semtech2011
Publishing Linked Data 3/5 Semtech2011
 
Comparative study on the processing of RDF in PHP
Comparative study on the processing of RDF in PHPComparative study on the processing of RDF in PHP
Comparative study on the processing of RDF in PHP
 
Introduction To RDF and RDFS
Introduction To RDF and RDFSIntroduction To RDF and RDFS
Introduction To RDF and RDFS
 
Introduction to RDF
Introduction to RDFIntroduction to RDF
Introduction to RDF
 
Chicago LOMRDF update 2003-06-19
Chicago LOMRDF update 2003-06-19 Chicago LOMRDF update 2003-06-19
Chicago LOMRDF update 2003-06-19
 

Más de Serge Linckels

Más de Serge Linckels (13)

Media IT - XML and XML Transformation (XSLT)
Media IT - XML and XML Transformation (XSLT)Media IT - XML and XML Transformation (XSLT)
Media IT - XML and XML Transformation (XSLT)
 
Media IT - XML and sublanguages
Media IT - XML and sublanguagesMedia IT - XML and sublanguages
Media IT - XML and sublanguages
 
Media IT - author rights
Media IT - author rightsMedia IT - author rights
Media IT - author rights
 
Media IT - Images
Media IT - ImagesMedia IT - Images
Media IT - Images
 
Media IT - Entropy
Media IT - EntropyMedia IT - Entropy
Media IT - Entropy
 
Media IT - Natural Language Processing
Media IT - Natural Language ProcessingMedia IT - Natural Language Processing
Media IT - Natural Language Processing
 
Media IT - Coding
Media IT - CodingMedia IT - Coding
Media IT - Coding
 
Semantic Web - Search engines
Semantic Web - Search enginesSemantic Web - Search engines
Semantic Web - Search engines
 
Semantic Web - Ontologies
Semantic Web - OntologiesSemantic Web - Ontologies
Semantic Web - Ontologies
 
Semantic Web - XML and sublanguages
Semantic Web - XML and sublanguagesSemantic Web - XML and sublanguages
Semantic Web - XML and sublanguages
 
Semantic Web - Overview
Semantic Web - OverviewSemantic Web - Overview
Semantic Web - Overview
 
Semantic Web - Introduction
Semantic Web - IntroductionSemantic Web - Introduction
Semantic Web - Introduction
 
E-Librarian Service
E-Librarian ServiceE-Librarian Service
E-Librarian Service
 

Último

Último (20)

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 

Semantic Web - RDF

  • 1. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 1 Semantic Web Unit 4: RDF and RDF Schema Faculty of Science, Technology and Communication (FSTC) Bachelor en informatique (professionnel)
  • 2. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 2 4. RDF and RDF Schema 2 Semantic Web Roadmap: Controlled growth bottom up according to this architecture. Architecture was (slightly) modified in the last years. 2
  • 3. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 3 4. RDF and RDF Schema 4.1. Why is XML not Sufficient? 4.2. RDF Specifications 4.3. RDF Schema (RDFS) 4.4. SPARQL – RDF Query Language 4.5. Sharing Vocabulary in RDF 4.6. Jena – RDF in Java 4.7. References 33
  • 4. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 4 4.1. Why is XML not Sufficient? 4. RDF and RDF Schema Level of knowledge representation and semantics XML / XML Schema objects, structure RDF / RDF Schema knowledge about objects, relations between objects OWL domain knowledge, interconnections 44
  • 5. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 5 4.1. Why is XML not Sufficient? 4. RDF and RDF Schema Problem 1: missing relational expressivity What is the relation between a "Professor", a "Secretary" and a "PhDStudent"? Christoph Meinel Viola Brehmer Long Wang Feng Cheng Dirk Cordel Serge Linckels Harald Sack <ChairMeinel> <Professor> <FirstName>Christoph</FirstName> <LastName>Meinel</LastName> </Professor> <Secretary>Viola Brehmer</Secretary> <PhDStudent>Long Wang</PhDStudent> <PhDStudent>Feng Cheng</PhDStudent> <PhDStudent>Dirk Cordel</PhDStudent> <PhDStudent>Serge Linckels</PhDStudent> <FormerPhDStudent>Harald Sack</FormerPhDStudent> </ChairMeinel> XML document We need a more powerful formalism above XML to describe relations between objects 55
  • 6. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 6 4.1. Why is XML not Sufficient? 4. RDF and RDF Schema Problem 2: missing relational expressivity Are all three documents equivalent? Do they represent the same information? <phonenumber> <owner>Serge Linckels</owner> <number>++352-691-123456</number> </phonenumber> XML document 1 We need a more powerful formalism above XML to describe objects with a shared vocabulary <person> <name>Serge Linckels</name> <phone>++352-691-123456</phone> </person> XML document 2 <person name="Serge Linckels" phone="++352-691-123456" /> XML document 3 Solving this kind of problem requires a matching of all 3 documents and their according DTD / XML Schema, e.g., with XSLT. This reengineering is difficult, complex and can be avoided. 66
  • 7. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 7 4.2. RDF Specifications 4. RDF and RDF Schema RDF overview Resource Description Framework RDF allows to describe resources in a more expressive way than XML RDF can be serialized as XML (or in other formats) The syntax of a RDF document can be described in a RDF Schema RDF documents can be queried using optimized query languages, e.g., SPARQL 77
  • 8. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 8 RDF English 4.2. RDF Specifications 4. RDF and RDF Schema RDF standard W3C recommendation Make statements (assertions) about resources, e.g., "Serge Linckels is a teacher. He teaches RDF." The object "Serge Linckels" has a property "hasJob" that has the value "teacher" The object "Serge Linckels" has a property "toTeach" that has the value "RDF" Statement 1 Statement 2 RDF statement A RDF statement is a "triple": resource – property – value teacherSerge Linckels hasJob Subject Predicate Object Resource Property Value 88
  • 9. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 9 4.2. RDF Specifications 4. RDF and RDF Schema RDF graph RDF statements are represented as directed and labeled graphs, where each resource is represented as a node Each resource is identified by a URI teacher hasJob RDF toTeach RDF graphs can be serialized in different formats, e.g., as XML RDF serialization <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:myNS="http://www.linckels.lu/myNS/"> <rdf:Description rdf:about="http://www.linckels.lu/"> <myNS:hasJob>teacher</myNS:hasJob> <myNS:toTeach>RDF</myNS:toTeach> </rdf:Description> </rdf:RDF> http://www.linckels.lu/ 99
  • 10. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 10 4.2. RDF Specifications 4. RDF and RDF Schema RDF validation RDF graphs can be validated with "a validator", e.g., http://www.w3.org/RDF/Validator/ 1010
  • 11. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 11 4.2. RDF Specifications 4. RDF and RDF Schema More about objects An RDF object can be a literal teacherSerge Linckels hasJob is a literal An RDF object can be a resource Serge Linckels worksWith is a resource Denis Zampuniéris <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:myNS="http://www.linckels.lu/myNS/"> <rdf:Description rdf:about="http://www.linckels.lu/"> <myNS:hasJob>teacher</myNS:hasJob> <myNS:worksWith rdf:resource="http://www.zampunieris.be" /> </rdf:Description> </rdf:RDF> 1111
  • 12. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 12 4.2. RDF Specifications 4. RDF and RDF Schema Example – RDF graph teacher RDF toTeach Les Générations Pascal professor Serge Linckels Denis Zampuniéris hasName hasJob hasName hasJob hasTitle http://www.zampunieris.be http://www.linckels.lu/ ISBN: 2-495-10604-8 1212
  • 13. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 13 4.2. RDF Specifications 4. RDF and RDF Schema Example – XML serialization <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:myNS="http://www.linckels.lu/myNS/"> <rdf:Description rdf:about="http://www.linckels.lu/"> <myNS:hasJob>teacher</myNS:hasJob> <myNS:hasName>Serge Linckels</myNS:hasName> <myNS:toTeach>RDF</myNS:toTeach> <myNS:worksWith rdf:resource="http://www.zampunieris.be/" /> </rdf:Description> <rdf:Description rdf:about="http://www.zampunieris.be/"> <myNS:hasJob>professor</myNS:hasJob> <myNS:hasName>Denis Zampunieris</myNS:hasName> <myNS:likesToRead rdf:resource="ISBN: 2-495-10604-8" /> </rdf:Description> <rdf:Description rdf:about="ISBN: 2-495-10604-8"> <myNS:hasTitle>Les Générations Pascal</myNS:hasTitle> <myNS:hasAuthor rdf:resource="http://www.linckels.lu/" /> </rdf:Description> </rdf:RDF> Related elements must not be nested within the elements they are related to 1313
  • 14. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 14 4.2. RDF Specifications 4. RDF and RDF Schema RDF directed graph – 3 types of nodes teacher hasJob http://www.linckels.lu/ Serge first Linckels last <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:myNS="http://www.linckels.lu/myNS/"> <rdf:Description rdf:about="http://www.linckels.lu/"> <myNS:fullname> <rdf:Description> <myNS:first>Serge</myNS:first> <myNS:last>Linckels</myNS:last> </rdf:Description> </myNS:fullname> <myNS:hasJob>teacher</myNS:hasJob> </rdf:Description> </rdf:RDF> uriref node blank node literal 1414
  • 15. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 15 4.2. RDF Specifications 4. RDF and RDF Schema RDF type attribute <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:myNS="http://www.linckels.lu/myNS/"> <rdf:Description rdf:about="http://www.linckels.lu/"> <myNS:hasName>Serge Linckels</myNS:hasName> <myNS:hasJob>teacher</myNS:hasJob> <rdf:type rdf:resource="http://www.linckels.lu/myNS/Person" /> </rdf:Description> </rdf:RDF> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:myNS="http://www.linckels.lu/myNS/"> <myNS:Person rdf:about="http://www.linckels.lu/"> <myNS:hasName>Serge Linckels</myNS:hasName> <myNS:hasJob>teacher</myNS:hasJob> </myNS:Person> </rdf:RDF> rdf:type explicitly specifies the type of a resource The following two examples are equivalent 1515
  • 16. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 16 4.2. RDF Specifications 4. RDF and RDF Schema RDF datatypes <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:myNS="http://www.linckels.lu/myNS/" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> <myNS:Person rdf:about="http://www.linckels.lu/"> <myNS:hasName rdf:datatype="xsd:string">Serge Linckels</myNS:hasName> <myNS:luckyNumber rdf:datatype="xsd:integer">12</myNS:luckyNumber> </myNS:Person> </rdf:RDF> rdf:datatype explicitly specifies the type of a literal No implicit semantics are attached to typed literals 1616
  • 17. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 17 rdf:Bag 4.2. RDF Specifications 4. RDF and RDF Schema RDF containers - example Serge Linckels http://www.linckels.lu/ Aviation _1 Krav Maga _2 hasName <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:myNS="http://www.linckels.lu/myNS/"> <rdf:Description rdf:about="http://www.linckels.lu/"> <myNS:hasHobbies> <rdf:Bag> <rdf:li>Aviation</rdf:li> <rdf:li>Krav Maga</rdf:li> </rdf:Bag> </myNS:hasHobbies> <myNS:hasName>Serge Linckels</myNS:hasName> </rdf:Description> </rdf:RDF> 1717
  • 18. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 18
  • 19. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 19 4.2. RDF Specifications 4. RDF and RDF Schema RDF containers - overview rdf:Bag – containing unordered lists of resources or literals, with duplicate data allowed rdf:Seq – containing ordered lists of resources or literals, with duplicate data allowed rdf:Alt – containing resources or literals that represent possible alternatives for a specific value RDF collections - overview Unlike a container, a collection is a finite grouping of resources or literals <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:myNS="http://www.linckels.lu/myNS/"> <rdf:Description rdf:about="http://www.linckels.lu/"> <myNS:hasFriends rdf:parseType="Collection"> <rdf:Description rdf:about="http://www.toto.lu" /> <rdf:Description rdf:about="http://www.titi.lu" /> <rdf:Description rdf:about="http://www.tata.lu" /> </myNS:hasFriends> <myNS:hasName>Serge Linckels</myNS:hasName> </rdf:Description> </rdf:RDF> 1919
  • 20. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 20 rdf:list 4.2. RDF Specifications 4. RDF and RDF Schema RDF lists Serge Linckels http://www.linckels.lu/ hasName http://www.toto.lu/ rdf:first http://www.titi.lu/ rdf:first rdf:rest http://www.tata.lu/ rdf:first rdf:rest rdf:nil rdf:rest A list is a terminated sequence of items Traversing a list becomes a matter of finding the start node and then accessing the next predicates for that node 2020
  • 21. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 21 4.2. RDF Specifications 4. RDF and RDF Schema RDF lists 21 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:myNS="http://www.linckels.lu/myNS/"> <rdf:Description rdf:about="http://www.linckels.lu/"> <myNS:hasFriends> <rdf:List> <rdf:first rdf:resource="http://www.toto.lu" /> <rdf:rest> <rdf:List> <rdf:first rdf:resource="http://www.titi.lu" /> <rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/> </rdf:List> </rdf:rest> </rdf:List> </myNS:hasFriends> <myNS:hasName>Serge Linckels</myNS:hasName> </rdf:Description> </rdf:RDF> 21
  • 22. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 22 rdf:Statement 4.2. RDF Specifications 4. RDF and RDF Schema Reification Reification is a method of formally modeling a statement about another statement sweetThis lemon are Serge Linckels says <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:myNS="http://www.linckels.lu/myNS/"> <rdf:Description rdf:about="http://www.linckels.lu/"> <myNS:says rdf:resource="#myStatement" /> </rdf:Description> <rdf:Statement rdf:about="#myStatement"> <rdf:subject rdf:resource="http://www.lemon123.lu" /> <rdf:predicate rdf:resource="myNS:are" /> <rdf:object>sweet</rdf:object> </rdf:Statement> </rdf:RDF> identification of the statement 2222
  • 23. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 23 4.2. RDF Specifications 4. RDF and RDF Schema rdf:Statement Reification – problem Reification is always an subjective view and can cause ambiguities sweetThis lemon are Serge Linckels says rdf:Statement bitter are DenisZampunieris says Who do you believe? 2323
  • 24. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 24 4.2. RDF Specifications 4. RDF and RDF Schema Reification is useful Useful to formally express trust 1.61803 π hasValue Serge Linckels says 3.14159 hasValue Who do you believe? A. Einstein D. Zampunieris M. Planck O. Hahn says says Create metadata over assertions (assertion ≠ fact) 2424
  • 25. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 25 Database 1 Database 2 4.2. RDF Specifications 4. RDF and RDF Schema RDF helps to make semantic relations between databases Les Générations Pascal hasAuthor http://www.linckels.lu/ ISBN: 2-495-10604-8 http://www.men.lu publishedBy http://www.myschool.lu http://www.men.lu hasProject Ministère de l'Éducation Nationale hasName Relations between distinct databases can made explicit  same URI = same resources Data can be integrated (from one database into another)  same URI, same vocabulary 2525
  • 26. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 26 4.2. RDF Specifications 4. RDF and RDF Schema RDF helps to make semantic relations between databases Relations between distinct databases can made explicit  same URI = same resources Data can be integrated (from one database into another)  same URI, same vocabulary 26 Les Générations Pascal hasAuthor http://www.linckels.lu/ ISBN: 2-495-10604-8 publishedBy hasTitle http://www.myschool.lu http://www.men.lu hasProject Ministère de l'Éducation Nationale hasName 26
  • 27. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 27 4.3. RDF Schema (RDFS) 4. RDF and RDF Schema RDFS overview RDFS specifies: - how RDF constructs relate to each other - how RDF constructs can be diagrammed in XML RDFS is a rules-based dictionary that: - defines the elements of importance to a domain - describes how these elements relate to one another RDF is a way of describing data RDFS is a domain-neutral way of describing the metadata that can be used to describe the data for domain-specific vocabulary RDFS allows to define: - abstract datatypes (classes) - hierarchically structure the datamodel - properties and relations (e.g., inheritance) 2727
  • 28. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 28 4.3. RDF Schema (RDFS) 4. RDF and RDF Schema RDFS – defining classes rdfs:Resource is the RDFS top-class rdfs:Resource myNS:Person fullname Example: <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> <rdfs:class rdf:about="http://www.linckels.lu/myNS/Person"> <rdfs:subClassOf rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Resource" /> </rdfs:class> <rdf:Property rdf:about="http://www.linckels.lu/myNS/fullname"> <rdfs:domain rdf:resource="http://www.linckels.lu/myNS/Person" /> </rdf:Property> </rdf:RDF> rdfs:class – definition of a new class that inherits from the super class specified in rdfs:subClassOf rdf:Property – definition of a new property of a class specified in rdfs:domain 2828
  • 29. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 29 4.3. RDF Schema (RDFS) 4. RDF and RDF Schema RDFS – defining a instance of a class <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:myNS="http://www.linckels.lu/myNS/"> <rdfs:class rdf:about="http://www.linckels.lu/myNS/Person"> <rdfs:subClassOf rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Resource" /> </rdfs:class> <rdf:Property rdf:about="http://www.linckels.lu/myNS/fullname"> <rdfs:domain rdf:resource="http://www.linckels.lu/myNS/Person" /> </rdf:Property> <myNS:Person rdf:about="http://www.linckels.lu/"> <myNS:fullname>Serge Linckels</myNS:fullname> </myNS:Person> </rdf:RDF> <rdf:Description rdf:about="http://www.linckels.lu/"> <myNS:fullname>Serge Linckels</myNS:fullname> <rdf:type rdf:resource="http://www.linckels.lu/myNS/Person" /> </rdf:Description> = 2929
  • 30. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 30 4.3. RDF Schema (RDFS) 4. RDF and RDF Schema RDFS – defining relations and restrictions rdfs:Resource myNS:Person worksFor age <rdf:Property rdf:about="http://www.linckels.lu/myNS/worksFor"> <rdfs:domain rdf:resource="http://www.linckels.lu/myNS/Person" /> <rdfs:range rdf:resource="http://www.linckels.lu/myNS/Firm" /> </rdf:Property> myNS:Firm rdfs:range – specifies the classes the property can reference as values <rdf:Property rdf:about="http://www.linckels.lu/myNS/age"> <rdfs:domain rdf:resource="http://www.linckels.lu/myNS/Person" /> <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer" /> </rdf:Property> This mechanism allows to define basic relations between classes and to define datatypes for property values A validator checks only the syntax, not if the values for properties are correct. This task must be assumed by the application. ! 3030
  • 31. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 31 4.3. RDF Schema (RDFS) 4. RDF and RDF Schema RDFS – other elements rdfs:label – provides a (human) readable version the resource's name rdfs:Literal - defines a node as being a literal value, not a resource rdfs:Comment – defines a comment rdfs:Container – superclass of all RDF container elements (rdf:Bag, rdf:Seq and rdf:Alt) rdfs:member – superproperty for each numbered container element (e.g., _1, _2, etc.) rdfs:subPropertyOf – specifies a property as a refinement of another property rdfs:seeAlso – identifies another resource that contains additional information rdfs:isDefinedBy – identifies the namespace for the resource, preventing any ambiguity 3131
  • 32. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 32 4.4. SPARQL – RDF Query Language 4. RDF and RDF Schema RDF query languages – overview There exists multiple languages to query RDF data: ARQ, RDQL, N3QL, RQL, SPARQL, SeRQL, Versa, XUL, Adenine, RDQ, N3QL… SPARQL (SPARQL Protocol and RDF Query Language) was standardized in January 2008 by the W3C "SQL like" syntax to query RDF data as triples @prefix myNS: <http://www.linckels.lu/myNS#> SELECT DISTINCT ?X FROM <http://www.linckels.lu/myRDF-file.rdf> WHERE { myNS:Person myNS:worksFor ?X . } Example: "show me all firms that have employees" Complex filtering is possible, e.g., - string operations - conjunctions and disjunctions of logical tests - datatype checking 32 triple 32
  • 33. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 33 4.4. SPARQL – RDF Query Language 4. RDF and RDF Schema RDF query languages – overview @prefix myNS: <http://www.linckels.lu/myNS#> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?person ?firm FROM <http://www.linckels.lu/myRDF-file.rdf> WHERE { ?person rdf:type myNS:Person . ?person myNS:worksFor ?firm . ?firm rdf:type myNS:Firm . ?person myNS:age ?age . FILTER (?age > 30) . FILTER (?age <= 40) . } Example: "show me all persons and the firms they work for, who are between 31 and 40 in age" 3333
  • 34. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 34 4.5. Sharing Vocabulary in RDF 4. RDF and RDF Schema Problem with not identical predicates Les Générations Pascal hasTitle ISBN: 2-495-10604-8 Les Générations Pascal avoirTitre ISBN: 2-495-10604-8 = ? - Resources are equal because same URI - Objects are equal because same value  are both predicates equal ? Use (as far as possible) existing vocabulary for predicates, or share your own vocabulary with others Examples: Dublin Core (DC), Friend of a Friend (FOAF) 3434
  • 35. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 35 4.5. Sharing Vocabulary in RDF 4. RDF and RDF Schema Dublin Core (DC) Les Générations Pascal dc:title ISBN: 2-495-10604-8 DC metadata element set is a standard for cross-domain information resource description Provides a simple and standardized set of conventions for describing resources DC is widely used to describe digital materials such as video, sound, image, text, and composite media like web pages Dublin Core is defined by NISO Standard Z39.85-2007 http://dublincore.org/ DC is controlled by Dublin Core Metadata Initiative (DCMI), an organization providing an open forum for the development of interoperable online metadata standards 3535
  • 36. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 36 4.5. Sharing Vocabulary in RDF 4. RDF and RDF Schema Dublin Core (DC) Simple Dublin Core Metadata Element Set (DCMES) consists of 15 metadata elements Qualified Dublin Core Metadata Element Set (QDCME) includes three additional elements (audience, provenance and rightsholder), as well as a group of element refinements title : a name given to a resource creator : an entity responsible for making the content of the resource subject : the topic of the content of the resource description : an account of the content of the resource publisher : an entity responsible for making the content available contributor : an entity responsible for making contributions to the content of the resource date : a date associated with an event in the life cycle of the resource type : the nature or genre of the content of the resource format : the physical or digital manifestation of the resource identifier : an unambiguous reference to the resource within a given context source : a reference to the resource from which the present resource is derived language : a language of the intellectual content of the resource relation : a reference to a related resource coverage : the extent or scope of the content of the resource rights : information about rights held in and over the resource 3636
  • 37. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 37 FOAF Basics Personal Info Online Accounts Projects & Groups Documents & Images 4.5. Sharing Vocabulary in RDF 4. RDF and RDF Schema Friend of a Friend (FOAF) FOAF is a way to describe people and relationships to computers; it is a vocabulary http://www.foaf-project.org/ Agent Person name nick title homepage mbox mbox_sha1sum img depiction surname family_name givenname firstName weblog knows interest currentProject pastProject plan based_near workplaceHomepage workInfoHomepage schoolHomepage topic_interest publications geekcode myersBriggs dnaChecksum OnlineAccount OnlineChatAccount OnlineEcommerceAccount OnlineGamingAccount holdsAccount accountServiceHomepage accountName icqChatID msnChatID aimChatID jabberID yahooChatID Project Organization Group member membershipClass fundedBy theme Document Image PersonalProfileDocument topic (page) primaryTopic tipjar sha1 made (maker) thumbnail logo 3737
  • 38. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 38 4.5. Sharing Vocabulary in RDF 4. RDF and RDF Schema Mixing Vocabularies <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:myNS="http://www.linckels.lu/myNS/"> <myNS:Person rdf:about="http://www.linckels.lu/"> <foaf:name>Serge Linckels</foaf:name> <myNS:toTeach>RDF</myNS:toTeach> </myNS:Person> <rdf:Description rdf:about="ISBN: 2-495-10604-8"> <dc:title>Les Générations Pascal</dc:title> <dc:creator rdf:resource="http://www.linckels.lu/" /> </rdf:Description> </rdf:RDF> 38 RDF myNS:toTeach Les Générations Pascal Serge Linckels dc:title dc:creator http://www.linckels.lu/ ISBN: 2-495-10604-8 38
  • 39. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 39 4.6. Jena – RDF in Java 4. RDF and RDF Schema Jena – overview Jena is a Java framework for building Semantic Web applications Jena provides a programmatic environment for RDF, RDFS, OWL and SPARQL Jena is open source and grown out of work with the HP Labs Semantic Web Programme http://jena.sourceforge.net/ 3939
  • 40. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 40 4.6. Jena – RDF in Java 4. RDF and RDF Schema Jena – example: creating a resource import com.hp.hpl.jena.mem.ModelMem; import com.hp.hpl.jena.rdf.model.*; static String myDemo= "http://www.linckels.lu/"; static String myNS = " http://www.linckels.lu/myNS"; // create an empty graph Model myModel = new ModelMem(); // create the resource Resource myResource = myModel.createResource(myDemo); // create the predicate (property) Property fullname = myModel.createProperty(myNS,"fullname"); // add the property with associated value (object) myResource.addProperty(fullname, "Serge Linckels"); // print RDF/XML of model to system out myModel.write(new PrintWriter(System.out)); 4040
  • 41. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 41 4.6. Jena – RDF in Java 4. RDF and RDF Schema Jena – example: browsing through a graph // using a statement iterator StmtIterator iter = myModel.listStatements(); while (iter.hasNext()) { // read a statement (resource, predicate, object) Statement stmt = iter.next(); // identify resource Resource subject = stmt.getSubject(); // identify predicate Property predicate = stmt.getPredicate(); // identify object RDFNode object = stmt.getObject(); // output System.out.print("("+predicate.toString()+","); System.out.print(subject.toString()+","); System.out.println(object.toString()+")"); } 4141
  • 42. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 42 4.6. Jena – RDF in Java 4. RDF and RDF Schema Jena – example: read and write a file String filename = "myFile.rdf"; // creating a model Model myModel = new ModelMem(); // read a file Model.read(new FileReader(filename)); // write a file Model.write(new PrintWriter(System.out)); Jena – example: creating a container Bag bag = myModel.createBag(); bag.add("Romeo and Juliet") bag.add("Hamlet") bag.add("Othello"); NodeIterator iter = bag.iterator(); while (iter.hasNext()) { System.out.println(" " + iter.next().toString()); } 4242
  • 43. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 43 Creating the Semantic Web with RDF: Professional Developer's Guide Johan Hjelm 4.7. References 4. RDF and RDF Schema Practical RDF Shelley Powers 4343 E-Librarian Service User-Friendly Semantic Search in Digital Libraries Serge Linckels, Christoph Meinel
  • 44. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 44 A Semantic Web Primer (Cooperative Information Systems) Grigoris Antoniou , Frank van Harmelen Semantic Web: Concepts, Technologies and Applications K.K. Breitman, M.A. Casanova, W. Truszkowski 4.7. References 4. RDF and RDF Schema 44 Foundations of Semantic Web Technologies Pascal Hitzler, Markus Krötzsch, Sebastian Rudolph 44