0% found this document useful (0 votes)
54 views44 pages

RDF and RDF Schema

The document discusses RDF and RDF Schema. RDF allows describing resources and relationships between them in a graph-based data model. RDF graphs can be serialized in XML and validated. RDF Schema provides a vocabulary for describing properties and classes of RDF resources.

Uploaded by

adi.hartanto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views44 pages

RDF and RDF Schema

The document discusses RDF and RDF Schema. RDF allows describing resources and relationships between them in a graph-based data model. RDF graphs can be serialized in XML and validated. RDF Schema provides a vocabulary for describing properties and classes of RDF resources.

Uploaded by

adi.hartanto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 44

Faculty of Science, Technology and Communication (FSTC)

Bachelor en informatique (professionnel)

Semantic Web
Unit 4: RDF and RDF Schema

Rules Trust
Data
Proof
Data
Logic

Signatur
Dig
Ontology
vocabula
ry

it a
RDF + RD
F Schem

l
e
a
XML + N
amespac
es + XML
Schema
•URI
•Unicode

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 1
4. RDF and RDF Schema

Semantic Web Roadmap:


Controlled growth bottom
up according to this
architecture.

Architecture was (slightly)


modified in the last years.

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 2
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

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 3
4. RDF and RDF Schema
4.1. Why is XML not Sufficient?
Level of knowledge representation and semantics

OWL
domain knowledge,
interconnections

RDF / RDF Schema


knowledge about
objects, relations
between objects

XML / XML Schema


objects, structure

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 4
4. RDF and RDF Schema
4.1. Why is XML not Sufficient?

?
Problem 1: missing relational expressivity
Christoph Meinel
Viola Brehmer
Long Wang
Feng Cheng XML document
Dirk Cordel <ChairMeinel>
Serge Linckels <Professor>
Harald Sack <FirstName>Christoph</FirstName>
<LastName>Meinel</LastName>
</Professor>
What is the relation between a <Secretary>Viola Brehmer</Secretary>
"Professor", a "Secretary" and a <PhDStudent>Long Wang</PhDStudent>
"PhDStudent"? <PhDStudent>Feng Cheng</PhDStudent>
<PhDStudent>Dirk Cordel</PhDStudent>
<PhDStudent>Serge Linckels</PhDStudent>
<FormerPhDStudent>Harald Sack</FormerPhDStudent>
</ChairMeinel>

We need a more powerful formalism above XML to


describe relations between objects

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 5
4. RDF and RDF Schema
4.1. Why is XML not Sufficient?
Problem 2: missing relational expressivity
XML document 1 XML document 2
<phonenumber> <person>
<owner>Serge Linckels</owner> <name>Serge Linckels</name>
<number>++352-691-123456</number> <phone>++352-691-123456</phone>
</phonenumber> </person>

XML document 3

?
<person name="Serge Linckels" phone="++352-691-123456" />

Are all three documents Solving this kind of problem requires a


equivalent? matching of all 3 documents and their
according DTD / XML Schema, e.g., with
Do they represent the XSLT. This reengineering is difficult,
same information? complex and can be avoided.

We need a more powerful formalism above XML to


describe objects with a shared vocabulary

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 6
4. RDF and RDF Schema
4.2. RDF Specifications
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

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 7
4. RDF and RDF Schema
4.2. RDF Specifications
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 Statement 1
the value "teacher"

The object "Serge Linckels" has a property "toTeach" that has Statement 2
the value "RDF"

RDF statement
A RDF statement is a "triple": resource – property – value

hasJob
Serge Linckels teacher

Subject Predicate Object English


Resource Property Value RDF

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 8
4. RDF and RDF Schema
4.2. RDF Specifications
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
hasJob
teacher

http://www.linckels.lu/
toTeach
RDF

RDF serialization
RDF graphs can be serialized in different formats, e.g., as XML
<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>

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 9
4. RDF and RDF Schema
4.2. RDF Specifications
RDF validation
RDF graphs can be validated with "a
validator", e.g.,
http://www.w3.org/RDF/Validator/

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 10
4. RDF and RDF Schema
4.2. RDF Specifications
More about objects
An RDF object can be a literal

hasJob
Serge Linckels teacher

is a literal

An RDF object can be a resource

worksWith
Serge Linckels Denis Zampuniéris

is a resource

<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>

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 11
4. RDF and RDF Schema
4.2. RDF Specifications
Example – RDF graph
hasTitle
Les Générations Pascal

ISBN: 2-495-10604-8
lik
e sT hasJob
oR professor
ea
d
h a s A u t h or

hasName
http://www.zampunieris.be Denis Zampuniéris
th
Wi
o rks
w hasJob
teacher

hasName
http://www.linckels.lu/ Serge Linckels
toTeach
RDF

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 12
4. RDF and RDF Schema
4.2. RDF Specifications
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>
Related elements
<rdf:Description rdf:about="http://www.zampunieris.be/"> must not be nested
<myNS:hasJob>professor</myNS:hasJob> within the elements
<myNS:hasName>Denis Zampunieris</myNS:hasName> they are related to
<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>

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 13
4. RDF and RDF Schema
4.2. RDF Specifications
RDF directed graph – 3 types of nodes
hasJob
uriref node teacher
literal
http://www.linckels.lu/
first
fullname Serge

last
Linckels
blank node

<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>

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 14
4. RDF and RDF Schema
4.2. RDF Specifications
RDF type attribute
rdf:type explicitly specifies the type of a resource

The following two examples are equivalent

<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>

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 15
4. RDF and RDF Schema
4.2. RDF Specifications
RDF datatypes
rdf:datatype explicitly specifies the type of a literal

No implicit semantics are attached to typed literals

<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>

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 16
4. RDF and RDF Schema
4.2. RDF Specifications
RDF containers - example
hasName
Serge Linckels
rdf:Bag
http://www.linckels.lu/ _1
h a sH
obbie Aviation
s
_2
Krav Maga

<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>

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 17
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 18
4. RDF and RDF Schema
4.2. RDF Specifications
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>

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 19
4. RDF and RDF Schema
4.2. RDF Specifications
RDF lists
hasName
Serge Linckels
rdf:list
http://www.linckels.lu/
ha s F
r i e nd
s rdf:first
http://www.toto.lu/

A list is a terminated sequence of


rdf:rest
items

Traversing a list becomes a rdf:first


matter of finding the start node http://www.titi.lu/
and then accessing the next
predicates for that node rdf:rest

rdf:first
http://www.tata.lu/

rdf:rest

rdf:nil

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 20
4. RDF and RDF Schema
4.2. RDF Specifications
RDF lists
<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>

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 21
4. RDF and RDF Schema
4.2. RDF Specifications
Reification
Serge Linckels
Reification is a method of formally
modeling a statement about another
statement says
rdf:Statement

are
This lemon sweet

<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> identification of
the statement
<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>

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 22
4. RDF and RDF Schema
4.2. RDF Specifications
Reification – problem
Reification is always an subjective view and can cause ambiguities

Who do you believe?


Serge Linckels

says
rdf:Statement

are
Denis Zampunieris

This lemon sweet

says

are

bitter

rdf:Statement

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 23
4. RDF and RDF Schema
4.2. RDF Specifications
Reification is useful
Useful to formally express trust

Create metadata over assertions (assertion ≠ fact)

Serge Linckels
Who do you believe?
says
sa
ys
A. Einstein

π
hasValue
1.61803
D. Zampunieris
sa
ys

hasValue
says
M. Planck

says
O. Hahn 3.14159

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 24
4. RDF and RDF Schema
4.2. RDF Specifications
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

Database 2
Database 1

Ministère de http://www.men.lu
l'Éducation
Nationale
publishedBy
hasName

ISBN: 2-495-10604-8

ha
http://www.men.lu

sT
itle
hasAuthor
hasProject Les Générations
Pascal

http://www.myschool.lu http://www.linckels.lu/

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 25
4. RDF and RDF Schema
4.2. RDF Specifications
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

Ministère de
l'Éducation
Nationale Les Générations
Pascal
hasName
hasTitle

publishedBy
http://www.men.lu ISBN: 2-495-10604-8

hasProject
hasAuthor

http://www.myschool.lu
http://www.linckels.lu/

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 26
4. RDF and RDF Schema
4.3. RDF Schema (RDFS)
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)

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 27
4. RDF and RDF Schema
4.3. RDF Schema (RDFS)
RDFS – defining classes rdfs:Resource

rdfs:class – definition of a new class that inherits from the super class
specified in rdfs:subClassOf

rdfs:Resource is the RDFS top-class

rdf:Property – definition of a new property of a class specified in


rdfs:domain 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>

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 28
4. RDF and RDF Schema
4.3. RDF Schema (RDFS)
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>

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 29
4. RDF and RDF Schema
4.3. RDF Schema (RDFS)
RDFS – defining relations and restrictions rdfs:Resource

rdfs:range – specifies the classes the property can


reference as values

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.
myNS:Firm 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>

<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>

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 30
4. RDF and RDF Schema
4.3. RDF Schema (RDFS)
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

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 31
4. RDF and RDF Schema
4.4. SPARQL – RDF Query Language
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

Example: "show me all firms that have employees"

@prefix myNS: <http://www.linckels.lu/myNS#>


SELECT DISTINCT ?X
FROM <http://www.linckels.lu/myRDF-file.rdf>
WHERE
{
myNS:Person myNS:worksFor ?X .
}
triple

Complex filtering is possible, e.g.,


- string operations
- conjunctions and disjunctions of logical tests
- datatype checking

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 32
4. RDF and RDF Schema
4.4. SPARQL – RDF Query Language
RDF query languages – overview
Example: "show me all persons and the firms they work for, who are between 31 and 40 in
age"

@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) .
}

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 33
4. RDF and RDF Schema
4.5. Sharing Vocabulary in RDF
Problem with not identical predicates

hasTitle
ISBN: 2-495-10604-8 Les Générations Pascal

avoirTitre
=?
ISBN: 2-495-10604-8 Les Générations Pascal

- 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)

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 34
4. RDF and RDF Schema
4.5. Sharing Vocabulary in RDF
Dublin Core (DC)
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

DC is controlled by Dublin Core Metadata Initiative (DCMI), an organization providing an open


forum for the development of interoperable online metadata standards

Dublin Core is defined by NISO Standard Z39.85-2007

http://dublincore.org/

dc:title
ISBN: 2-495-10604-8 Les Générations Pascal

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 35
4. RDF and RDF Schema
4.5. Sharing Vocabulary in RDF
Dublin Core (DC)
Simple Dublin Core Metadata Element Set (DCMES) consists of 15 metadata elements

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

Qualified Dublin Core Metadata Element Set (QDCME) includes three additional elements
(audience, provenance and rightsholder), as well as a group of element refinements

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 36
4. RDF and RDF Schema
4.5. Sharing Vocabulary in RDF
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 weblog OnlineAccount Document


Person knows OnlineChatAccount Image
name interest OnlineEcommerceAccount PersonalProfileDocument
nick currentProject OnlineGamingAccount topic (page)
title pastProject holdsAccount primaryTopic
homepage plan accountServiceHomepage tipjar
mbox based_near accountName sha1
mbox_sha1sum workplaceHomepage icqChatID made (maker)
img workInfoHomepage msnChatID thumbnail
depiction schoolHomepage aimChatID logo
surname topic_interest jabberID Projects & Groups
family_name publications yahooChatID
givenname geekcode Online Accounts Project
firstName myersBriggs Organization
FOAF Basics dnaChecksum Group
Personal Info member
membershipClass
fundedBy
Documents & Images theme

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 37
4. RDF and RDF Schema
4.5. Sharing Vocabulary in RDF
Mixing Vocabularies
dc:title
ISBN: 2-495-10604-8 Les Générations Pascal

dc:creator e Serge Linckels


am
foaf:n

http://www.linckels.lu/ RDF
myNS:toTeach

<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>
Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 38
4. RDF and RDF Schema
4.6. Jena – RDF in Java
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/

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 39
4. RDF and RDF Schema
4.6. Jena – RDF in Java
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));

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 40
4. RDF and RDF Schema
4.6. Jena – RDF in Java
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()+")");
}

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 41
4. RDF and RDF Schema
4.6. Jena – RDF in Java
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());
}

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 42
4. RDF and RDF Schema
4.7. References

E-Librarian Service
User-Friendly Semantic Search in Digital Libraries
Serge Linckels, Christoph Meinel

Creating the Semantic Web with RDF: Professional Developer's Guide


Johan Hjelm

Practical RDF
Shelley Powers

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 43
4. RDF and RDF Schema
4.7. References

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

Foundations of Semantic Web Technologies


Pascal Hitzler, Markus Krötzsch, Sebastian Rudolph

Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 44

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy