59
Web – technologies / weekly exercises Answers (1/1) <person> <name> <first_name>Alan</first_name> <last_name>Turing></last_name> </name> <profession>computer scientists</profession> <profession>mathematician</profession> <profession>cryptographer</profession> </person>

Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Embed Size (px)

Citation preview

Page 1: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / weekly exercisesAnswers (1/1)

<person><name>

<first_name>Alan</first_name><last_name>Turing></last_name>

</name><profession>computer scientists</profession><profession>mathematician</profession><profession>cryptographer</profession>

</person>

Page 2: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / Weekly exercisesNumber 1

1. Give an XML-document (by not using attributes), which includes the information that the first name of a person is Alan, his last name is Turing, and his professions are computer scientist, mathematician and cryptographer.

2. Give the tree diagram of the document given in 1.

3. Modify the document given in exercise 1 such that the “first” and “last” are the attributes of the name element

Page 3: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / weekly exercisesAnswers (1/2)

person

name profession profession profession

first_name last-name

Alan Turing

computerscientist mathematician cryptographer

Page 4: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / weekly exercisesAnswers (1/3)

<person first_name=“Alan” last_name=“Turing”> <profession>computer scientists</profession><profession>mathematician</profession><profession>cryptographer</profession>

</person>

Page 5: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / Weekly exercisesNumber 2

1. Give an XML-document (by not using attributes), which includes the following information: the social security number (123456789A), the first name of a person is Jack, and his last name is Taylor, his address is composed of postcode (0500), city (Boston) and street (Hamilton street), and his telephone numbers are 12345 and 6789.

2. Give the tree diagram of the document given in exercise 1.

3. Give a DTD (Document Type Definition) for the XML-document specified in exercise 1.

4. Give an XML Schema for the information specified in exercise 1.Validate the schema using the validator located at : http://www.stg.brown.edu/service/xmlvalid/

5. Give an instance of a the XML Schema specified in exercise 4.

Page 6: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / weekly exercisesAnswers (1/2)

<person><social_security_number>123456789A</social_security_number>

<name><first_name>Jack</first_name><last_name>Taylor</last_name>

</name><address>

<city>Boston</city><postcode>0500</postcode><street>Hamilton Street></street>

</address><telephone_number>12345</telephone_number><telephone_number>12345</telephone_number>

</person>

Page 7: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / weekly exercisesAnswers (2/2)

Person

Social_security-number

name

first_name

last_name

address

city postcode street

Telephone_number

12345

Telephone_number

67891234..9A

Jack TaylorBoston 0500 Hamilton street

Page 8: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / weekly exercisesAnswers (3/2)

<!ELEMENT person (social_security_number, name address, telephone_number*)><!ELEMENT social_security_number (#PCDATA)><!ELEMENT name (first_name, last_name)><!ELEMENT first_name (#PCDATA)><!ELEMENT last_name (#PCDATA)><!ELEMENT address (city, postcode, street)><!ELEMENT city (#PCDATA)><!ELEMENT postcode (#PCDATA)><!ELEMENT street (#PCDATA)><!ELEMENT telephone_number (#PCDATA)>

Page 9: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / weekly exercisesAnswers (4/2)

<xsd: element name = “person”> <xsd: complexType> <xsd: element name = “ name”>

<xsd: complexType><xsd: element name = “first_name” type = “xsd: string” /><xsd: element name = “last_name” type = “xsd: string” />

</xsd: complexType> </XSD:element> <xsd: element name = “ address”>

<xsd: complexType><xsd: element name = “city” type = “xsd: string” /><xsd: element name = “postcode” type = “xsd: integer” /><xsd: element name = “street” type = “xsd: string” />

</xsd: complexType> </XSD:element><xsd: element name = “telephone_number” type “xsd:string”

minoccurs=“1” maxOccurs=“unbounded” /> <xsd: attribute name = “social_security_number” type “xsd:string” /> </xsd: complexType></XSD:element>

Page 10: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / weekly exercisesAnswers (5/2)

<person social_security_number = “123456789A”>

<name>

<first_name>Jack</first_name>

<last_name>Taylor</last_name>

</name>

<address>

<city>Boston</city>

<postcode>0500</postcode>

<street>Hamilton </Street>

</address>

<telephone_number>12345</telephone_number>

<telephone_number>12345</telephone_number>

</person>

Page 11: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / Weekly exercisesNumber 3

1. Give a conceptual schema (using ER-design) about teams, players, and their fans, including

• For each team, its name, its players, its team captain (one of its players), and the colors of its uniform.

• For each player, his/her name.• For each fan, his/her name, favorite teams, favorite players, and favorite color.

2. Do exercise 1 using UML-design

3. Capture the knowledge, using the graph of N3 notation, of the following English statements:

– Jack Smith studies at Helsinki University– Helsinki University has a web site at http://www.helsinki.fi/university/– Jack is a friend of Elisa Ford– Elisa Ford studies at Lappeenranta University of Technology– Lappeenranta University of Technology has a website at http://www.lut.fi/en/– Elisa Ford has a website at http://www.lut.fi/elisa

4. Using UML give a schema for the statements given in exercise 3.

Page 12: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / Weekly exercisesAnswers 3Answer 3.1

TeamPlayer

Color Fan

plays

is-captain

uniforms-colors

favorite-players

favorite-teams

favorite-color

namename

namecolor-name

Page 13: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / Weekly exercisesAnswers 3

Teamnameuniform_colors

Playernameplays-inis_captain

Fannamefavorite colorfavorite_palyerfavorite_teams

Answer 3.2

Page 14: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / Weekly exercisesAnswers 3

#Jack Smith #studies_at#Helsinki University #has-website

http://www.helsinki.fi/university

#Elisa Ford#studies-at

#Lappeenranta University of Technology

#has-websitehttp://www.lut.fi/en

#friend-of

http://www.lut.fi/elisa

#has-website

Answer 3.3

Page 15: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / Weekly exercisesAnswers 3

Personnamehas-websitefriend-ofstudies-at

Universitynamehas-website

Answer 3.4

Page 16: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / Weekly exercisesNumber 4

1. Modify the xml file of the slide page 198 and the style sheet presented at pages 201 and 202 such that the final layout would look as follows

Project:Trumantruck.com

Work Schedule

Date Description2000025 Taking Truck Body Apart2000225 Sandblasting Dismantling Cab2000311 Sanding, Priming Hood and Fender

Hours234

Page 17: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / Weekly exercisesAnswers Number 4

Answer 4.1

<?xml version=“1.0” encoding=“UTF-8”?><?xml-stylesheet href=“simple.xsl” type=“text/XSL”?><project name=Trumantruck.com”>

<description>Rebuilding a 1967 Chevy Pickup Truck</description><schedule>

<workday><date>20000205></date><description>Taking Truck Body Apart</description><hours>2</hours>

</workday> <workday>

<date>20000225></date><description>Sandblasting, Dismantling Cab</description><hours>3</hours>

</workday> <workday>

<date>200003111></date><description>Sanding, Priming Hood and Fender</description><hours>4</hours>

</workday> </schedule>

</project>

Page 18: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / Weekly exercisesAnswers Number 4

<xsl:stylesheet xmln:xsl=http://www.w3.org/TR/WD-xsl> <xsl:template match=“/”> <html>

<TITLE> Schedule For<xsl:value-of select=“/project/@name”/>

<xsl: value-of select=“/project/description”/></TITLE><CENTER>

<TABLE border=“1”><TR> <TD><B>Date</B></TD> <TD><B>Description</B></TD> <TD><B>Hours</B></TD></TR><xsl:apply-templates/>

</TABLE></CENTRE> </html>

</xsl:template>

Answer 4.1 continues

Page 19: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / Weekly exercisesAnswers Number 4

Answer 4.1 continues

<xsl: template match=“project”> <H1> Project : <xsl: value-of select=@name”/> </H1> <HR/> <xsl : apply-template/><xsl : template match = “schedule”> <H2> Work Schedule</H2>

<xsl:apply-templates/></xsl : template><xsl : template match = “workday”> <TR> <TD>

<xsl : value –of select =“date”/> </TD> <TD>

<xsl : value -of select=“description”/> </TD> <TD>

<xsl : value -of select=“hours”/> </TD> </TR></xsl : template>

</xsl : stylesheet>

Page 20: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Web – technologies / Weekly exercisesNumber 5

1. Give an a taxonomy, which can be used in classifying learning objects of computer science.

2. Give a thesarus that describes information entities such as course, laboratory course, exercise, exam, class room, course course book, laboratory, lecturer and laboratory room.

3. Give a conceptual schema using ER-schema notation that models the entities stated in exercise 2 and their relationships.

4. State using first order predicate logic “everyone who has enrolment of the Java course has a registration on that course”.

Page 21: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

RDF-exercises

Page 22: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

RDF-Exercise 1.

Give an RDF_description that states the following:

Resource http: //www.hut.fi/~jack/homepage is a homepage and it is owned by Jack Taylor.

Answer RDF-Excercise 1.

<?xml version =”1.0” encoding_”UTF-16”?>

<rdf : RDF

xmlns : rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#”

xmlns : mydomain = http://www.mydomain.org/my-rdf-ns”>

<rdf : Description rdf : about = ” http: //www.hut.fi/~jack/homepage”>

<mydomain : homepage-owner> Jack Taylor </mydomain : homepage-owner>

</rdf : Description>

</rfd: RDF>

Page 23: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

RDF-Exercise 2.

Give an RDF_description that states the following:

Resource http: //www.innouni.fi/innouni-ns/#T-999”> is a course named Java-programming and is lectured by Lisa Smith at room T2.

Answer RDF-Excercise 2.

<?xml version =”1.0” encoding_”UTF-16”?>

<rdf : RDF

xmlns : rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#”

xmlns : mydomain = http://www.mydomain.org/my-rdf-ns”>

<rdf : Description rdf : about = ” http: //www.innouni.fi/innouni-ns/#T-999”>

<mydomain : course-name> Java-programming </mydomain : course-name>

<mydomain : course-lecturer> Lisa Smith </mydomain : course-lecturer>

<mydomain : lecture-room> T2 </mydomain : lecture-room>

</rdf : Description>

</rfd: RDF>

Page 24: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

RDF-Exercise 3. By using container elemn rdf :Bag, give an RDF_description that states the

following: Mary and John owns the car ABC-99Answer RDF-Excercise 3.

<?xml version =”1.0” encoding_”UTF-16”?><rdf : RDF

xmlns : rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#”xmlns : mydomain = http://www.mydomain.org/my-rdf-ns”>

<rdf : Description rdf : about = ” #ABC-99”><mydomain : owns><rdf : Bag>

<rdf : _li rdf : resource= ”#Mary”/><rdf : _li rdf : resource= ”#John”/>

</mydomain : owns></rdf : Description>

</rfd: RDF>

Page 25: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

RDF-Exercise 4. By using the ”collection” value of the rdf : parseType attribute give an

RDF_description that states the following: Mary and John owns the car ABC-99

Answer RDF-Excercise 4.

<?xml version =”1.0” encoding_”UTF-16”?><rdf : RDF

xmlns : rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#”xmlns : mydomain = http://www.mydomain.org/my-rdf-ns”>

<rdf : Description rdf : about = ” #ABC-99”><mydomain: owns rdf : parseType = ”Collection”>

<rdf : Description rdf: about = ”#Mary”/><rdf : Description rdf: about = ”#John”/>

</mydomain : owns></rdf : Description>

</rfd: RDF>

Page 26: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

RDF Schema-exercises

Page 27: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

RDFS-Exercise 1.

Give a graphical presentation and RDF Schema that describe the following: Professors and assistants are subclasses of teachers. Each techer has a name. Each course has a course_id. Professors lecture courses while assistants suprervise courses.

Teacher

Professor

Assistant

Course

course_id

teacher_name

Literal

Literal

supervises

lectures

subClassOf

subClassOf

domain

rangedomain

rangedomain

range

domainrange

Page 28: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

<rdf : RDFxmlns : rdf=”http://www.w3.org/1999/02/22-rdf-syntax-ns#”xmlns : rdfs=http://www.w3.org/2000/01/rdf-schema#”>

<rdfs:Class rdf:ID=”assistant”> <rdfs:comment>The class of assistants.</rdfs:comment> <rdfs:subClassOf rdf:resource=“teacher”/>

</rdfs:Class>

<rdfs:Class rdf:ID=”professor”> <rdfs:comment>The class of professors.</rdfs:comment> <rdfs:subClassOf rdf:resource=“teacher”/>

</rdfs:Class>

<rdfs:Class rdf:ID=”teacher”> <rdfs:comment>The class of teachers</rdfs:comment>

</rdfs:Class>

<rdfs:Class rdf:ID=”course”> <rdfs:comment>The class of courses</rdfs:comment>

</rdfs:Class>

Page 29: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

<rdfs:Property rdf:ID=”lectures”>

<rdfs:comment>

It relates professors to courses

</rdfs:comment>

<rdfs:domain rdf:resource=“#professor”/>

<rdfs:range rdf:resource=“#course”/>

</rdfs:Property>

<rdfs:Property rdf:ID=”supervises”>

<rdfs:comment>

It relates assistants to courses

</rdfs:comment>

<rdfs:domain rdf:resource=“#assistant”/>

<rdfs:range rdf:resource=“#course”/>

</rdfs:Property>

Page 30: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

<rdfs:Property rdf:ID=”lecturer_name”> <rdfs:comment> It is a property of teachers and takes literals as values. </rdfs:comment> <rdfs:domain rdf:resource=“#teacher”/> <rdfs:range rdf:resource=“&rdf;Literal”/></rdfs:Propert>

<rdfs:Property rdf:ID=”course_id”> <rdfs:comment> It is a property of courses and takes literals as values. </rdfs:comment> <rdfs:domain rdf:resource=“#course”/> <rdfs:range rdf:resource=“&rdf;Literal”/></rdfs:Propert>

</rdf:RDF>

Page 31: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Execise 2. RQL-Exercise .

By using RQL and the RDF Schema of the previous exercise give the following queries:

a) Retrieve all the instances of the class Teacher

b) Retrieve aal the inatances of the class Teacher that are iether profwssors or assistanra.

c) Retrieve the names of the assistants.

Answers:

a) teacher

b) ^teacher

c) select X, Y

from assistant{X} . teacher_name {Y}

Page 32: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Execise 3.

Discuss the difference vbetween the following statements, and draw graphs to illustrate the difference: X supports the proposal; Y supports the propodsal;

Z supports the proposal. The group of X, Y, and Z supports the proposal.

Draw graphs to illustrate the difference.

X the proposalsupports

Y the proposalsupports

Z the proposalsupports

Page 33: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

X

Y

Z

the proposalsupports

the group

belongs

belongs

belongs

Page 34: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Exercise 4. Compare rdfs:subClassOf with type extension in XML Schema

Page 35: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Exercise 5. Try to map the relational database model on RDF.

Page 36: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Exercise 6. Compare entity-relationship modelling to RDF.

Page 37: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Exercise 7.Model part of a library in RDF Schema: books, authors, publishers, years, copies, dates, and so on. Then write some statements in RDF, and query them using RQL.

Book

Author

Publisher

year

Copy

writtenBydomain

literal

range

domain

range

publishedBy

domain

rangepresents

copyNumber

literal

domain

range

publishretName

literal

domain

rangeISBN

literal

range

domain

Page 38: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

<rdf:RDFxmlns:rdf=“http.w3.org/1999/02/22-rdf-syntax-ns#”xmlns:rdfs=“http.w3.org/2000/01/rdf-schema#”>

<rdfs:Class rdf:ID=”book”> <rdfs:comment>The class of books</rdfs:comment>

</rdfs:Class>

<rdfs:Class rdf:ID=”publisher”> <rdfs:comment>The class of publishers</rdfs:comment>

</rdfs:Class>

<rdfs:Property rdf:ID=”publishedBy”> <rdfs:comment> It relates books to publishers </rdfs:comment> <rdfs:domain rdf:resource=“#book”/> <rdfs:range rdf:resource=“#publisher”/>

</rdfs:Property>

Page 39: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

<rdfs:Property rdf:ID=”ISBN”>

<rdfs:comment>

It is a property of books and takes literals as values.

</rdfs:comment>

<rdfs:domain rdf:resource=“#book”/>

<rdfs:range rdf:resource=“&rdf;Literal”/>

</rdfs:Propert>

</rdf:RDF>

Page 40: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

RDF-satatements

<mydomain: book rdf:ID=”12345”

mydomain: ISBN = ”abc567”>

<mydomain: publishedBy rdf:resource=”#Prenticee_Hall”/>

<mydomain: writternBy rdf:resourcre= ”#Jack_Smith”/>

</mydomain:book>

The same RDF-description by not using abbreviated syntax

<rdf: Description rdf: ID=”12345”>

<rdf : type rdf : resource=”&mydomain ; book”/>

<mydomain : ISBN> abc567 </mydomain : ISBN>

<mydomain: publishedBy rdf:resource=”#Prenticee_Hall”/>

<mydomain: writternBy rdf:resourcre= ”#Jack_Smith”/>

</rdf : Description>

Page 41: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

• Queries:

a) Retrieve all the instances of the book class?

Anwer: book

b) Retrieve all books and their ISBN:s:

Answer: select X, Y

from book {X} . ISBN {y}

c) Retrieve all the ISBN:s of the books published by Prentice-Hall

Answer: select Nfrom book {X} . publishedBy {Y}, {C} ISBN {N}

where Y= ”Prentice-Hall” and X=C

Page 42: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Exercise 8. Write an ontology about geography: cities, countries, capitals, borders, states, and so on.

country border

city

capital

state

isSubClassOff

belongs

domain

range

isPartOf

domain

range

domain

range

locates

countryName

literal

range

domain

Page 43: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

<rdf:RDFxmlns:rdf=“http.w3.org/1999/02/22-rdf-syntax-ns#”xmlns:rdfs=“http.w3.org/2000/01/rdf-schema#”>

<rdfs:Class rdf:ID=”country”> <rdfs:comment>The class of countries</rdfs:comment>

</rdfs:Class>

<rdfs:Class rdf:ID=”city”> <rdfs:comment>The class of cities</rdfs:comment>

</rdfs:Class>

<rdfs:Class rdf:ID=”state”> <rdfs:comment>The class of states</rdfs:comment>

</rdfs:Class>

<rdfs:Property rdf:ID=”belongs”> <rdfs:comment> It relates cities to countries </rdfs:comment> <rdfs:domain rdf:resource=“#city”/> <rdfs:range rdf:resource=“#country”/>

</rdfs:Property>

Page 44: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

<rdfs:Property rdf:ID=”locates”> <rdfs:comment> It relates cities to states </rdfs:comment> <rdfs:domain rdf:resource=“#city”/> <rdfs:range rdf:resource=“#state”/>

</rdfs:Property>

<rdfs:Property rdf:ID=”isPartOf”> <rdfs:comment> It relates states to countries </rdfs:comment> <rdfs:domain rdf:resource=“#state”/> <rdfs:range rdf:resource=“#country”/>

</rdfs:Property>

<rdfs:Class rdf:ID=”capital”> <rdfs:comment> The class of capitals </rdfs:comment> <rdfs:subClassOf rdf:resource=“city”/>

</rdfs:Class>

Page 45: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

<rdfs:Property rdf:ID=”border”>

<rdfs:comment>

It relates bordersto countries

</rdfs:comment>

<rdfs:domain rdf:resource=“#country”/>

<rdfs:range rdf:resource=“#country”/>

</rdfs:Property>

<rdfs:Property rdf:ID=”countryName”>

<rdfs:comment>

It is a property of countries and takes literals as values.

</rdfs:comment>

<rdfs:domain rdf:resource=“#country”/>

<rdfs:range rdf:resource=“&rdf;Literal”/>

</rdfs:Propert>

</rdf:RDF>

Page 46: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Exercise 9. Consider the classes of males and females. Name a relationship between them that should be included in an ontology.

Answer: relationship husbendOf; inverse wifeOf

Page 47: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Exercise 10. Consider the classes of persons, males and females. Name a relationship between all the three that should be included in an ontology. Which part of this relationship can be expressed in RDF Schema.

Answer. Husband, Wife, Mother, Father

Page 48: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Exercise 11. Suppose we declare Bob and Peter to be the father of Mary. Obviously there is a semantic error here. How should the semantic model make this error impossible?

Answer: by a cardinality restriction.

Page 49: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Exercise 12. What relationship exist between ”is child of” and ”is parent of” ?

Answer: inverse relationship

Page 50: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Exercise 13. Consider the property eats with domain animal and range animal or plant. Suppose we define a new class vegetarian. Name a desirable restriction on eats for this class. Do you think that this restriction can be expressed in RDF Schema by using rdfs : range ?

Answer: Specifying a subclass by restrictiong the range of a property is outside the expression power of RDF Schema. In particular, rdfs : range defines the range, e.g., eats, for all classes.

Page 51: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

OWL-exercises

Page 52: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

OWL-Exercise 1. Give an OWL-ontology that describes the following: There are courses and laboratory courses. Homeworks are part of courses. Courses are organized by teachers. Teachers are either professors or assistants. Professors teach courses while assistants only teach laboratory courses.

course

homeworklaboratory-course

teacher

professor

assistant

isPartOf subClassOf

organize

teach

teach

subClassOf

subClassOf

Page 53: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

<rdf:RDF

xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-nsl#

xmlns:rdfs=http://www.w3.org/2000/01/rdf-schema#

xmlns:owl=http://www.w3.org/2002/07/owl#

<owl:Ontology rdf:about=“”/>

<owl:Class rdf:ID=“course”>

<rdfs:comment>Courses form a class.</rdfs:comment>

</owl:Class>

<owl:Class rdf:ID=“laboratoryCourse”>

<rdfs:comment>Laboratory course is a type of course.</rdfs:comment>

<rdfs:subClassOf rdf:resource=“#course”/>

</owl:Class>

<owl:Class rdf:ID=“homework”>

<rdfs:subClassOf>

<owl:Restriction>

<owl:onProperty rdf:resoyrce=“#is_part_of”/>

<owl:allValuesFrom rdf:resource=“#course”/>

</owl:Restriction>

</rdfs:subClassOf></owl:Class>

Page 54: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

<owl:Class rdf:ID=“teacher”>

<rdfs:comment>Teachers form a class.</rdfs:comment>

</owl:Class>

<owl:Class rdf:ID=“assistant”>

<rdfs:comment>Assistants are exactly those teachers that teach laboratory courses.</rdfs:comment>

<owl:intersectionOf rdf:parseType=“Collection”>

<owl:Class rdf:about=“#teacher”/>

<owl:Restriction>

<owl:onProperty rdf:resoyrce=“#teach”/>

<owl:allValuesFrom rdf:resorce=“#laboratoryCourse”/>

</owl:Restriction>

</owl:intersectionOf >

</owl:Class>

Page 55: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

<owl:Class rdf:ID=“professor”>

<rdfs:comment>Professors are exactly those teachers that teach laboratory courses.</rdfs:comment>

<owl:intersectionOf rdf:parseType=“Collection”>

<owl:Class rdf:about=“#teacher”/>

<owl:Restriction>

<owl:onProperty rdf:resoyrce=“#teach”/>

<owl:someValuesFrom rdf:resorce=“#course”/>

</owl:Restriction>

</owl:intersectionOf >

</owl:Class>

<owl:TransitiveProperty rdf:ID=“is_part_of”/>

<owl:ObjectProperty rdf:ID=“teachs”>

<rdfs:domain rdf:resource=“#teacher”/>

</owl:ObjectProperty>

</rdf:RDF>

Page 56: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

OWL-Exercise 2. Give an OWL-ontology that describes the following:

a) Medicinal products are either over the counter drugs or prescription based drugs. Each medicinal product includes an active substance. In addition each medicinal product is substitutable by zero or more medicinal products.

b) Panadol is an instance of over the counter drug, Tramadol is an instance of prescription based drug, and Loperamide is an instance of active substance.

activesubstance

medicinalproduct

prescriptionbased drug

over the counter drug

Panadol

is_subClass_of

is_subClass_ofinstance_of

Tramadol

Instance_of

includes

Loperamide

Instance_of

Is-substitutable

Page 57: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Answer a)

<rdf:RDFxmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-nsl#xmlns:rdfs=http://www.w3.org/2000/01/rdf-schema#xmlns:owl=http://www.w3.org/2002/07/owl#<owl:Ontology rdf:about=“”/>

<owl:Class rdf:ID=“medicinalProduct”><rdfs:comment>Medicinal products form a class.</rdfs:comment>

</owl:Class><owl:Class rdf:ID=“overTheCounterDrug”>

<rdfs:subClassOf rdf:resource=“#medicinalProduct”/><owl : disjointWith rdf : resource= ”#prescriptionBasedDrug”/>

</owl:Class><owl:Class rdf:ID=“prescriptionBasedDrug”>

<rdfs:subClassOf rdf:resource=“#medicinalProduct”/><owl : disjointWith rdf : resource= ”#overTheCounterDrug”/>

</owl:Class><owl:Class rdf:ID=“activeSubstance”>

<owl : disjointWith rdf : resource= ”#medicinalProduct”/></owl:Class>

Page 58: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

<owl:ObjectProperty rdf:ID=“includes”>

<rdfs:domain rdf:resource=“#medicinalProduct”/>

<rdfs:range rdf:resource=“#activeSubstance”/>

</owl:ObjectProperty>

<owl:TransitiveProperty rdf:ID=“substitutes”>

<rdfs:domain rdf:resource=“#medicinalProduct”/>

<rdfs:range rdf:resource=“#medicinalProduct”/>

</owl:ObjectProperty>

</rdf:RDF

Page 59: Web – technologies / weekly exercises Answers (1/1) Alan Turing> computer scientists mathematician cryptographer

Answer b)

<rdf Description rdf : ID=”Panadol”/>

<rdf : type rdf : resource= ”#overTheCounterDrug”/>

</rdf : Description>

<rdf Description rdf : ID=”Tramadoldol”/>

<rdf : type rdf : resource= ”#prescriptionBasedDrug”/>

</rdf : Description>

<rdf Description rdf : ID=”Lopermide”/>

<rdf : type rdf : resource= ”# activeSubstance”/>

</rdf : Description>