Ein paar Kommentare zur Relevanz der einzelnen Vorlesungskapitel (entspricht weitgehend den Infos aus der letzten Vorlesung, s. Table of Contents:
http://www.inf.uni-konstanz.de/dbis/teaching/ws0708/xml/Inhalt.pdf
). Wichtig: die Zusammenfassung dient nur als Richtlinie; v.a. solltet Ihr Euch auch die Übungen nochmal ansehen:
1.1. irrelevant
2.2-2.4. die wichtigsten Konzepte sollten bewusst sein, Details irrel.
3.5-3.7... ebenso: kein Detailwissen verlangt
4.8-4.11: relevant
5.12-5.13: irrelevant
5.14: relevant
5.15: XPath Accelerator & Staircase Join relevant
5.16-5.17: Konzepte sollten verstanden werden, techn. Details irrelevant
5.18: irrelevant (..happy? ;)
5.19-6.23: once more: Konzepte, keine Implementierungsdetails Native XML Processing/Info Retrieval/XQuery Fulltext: kein Detailfragen
Übungsklausur:
A
1) /descend::titel[following-sibling::mitarbeiter/assistent]
2) /descendant::titel[count(following-sibling::mitarbeiter/assistent) >= 2]
3) /descendant::node()/vorlesung[mitarbeiter/*/@id="seifert"]/preceding::node()/vorlesung
4) /descendant::vorlesung[count(following::vorlesung)=0]
5) /descendant::dozent[@id="scholl"]/parent::*/parent::vorlesung
Welche Vorlesungen werden vom Dozent mi der id "scholl" betreut
/descendant::vorlesung[mitarbeiter/dozent/@id="scholl"]
Übung 3 XPath
1) Print all countries which are stored in the XML document
descendant::country/@name
2) How many countries can be found?
count(descendant::country)
231
3) Print the names of all Chinese cities
descendant::country[./@name = "China"]/descendant-or-self::city/name/text()
4) How many people live in Bangladesh?
descendant::country[./@name = Bangladesh]/@population
5) In which countries live more than 10 million people?
descendant::country[./@population > 10000000]/@name
6) Find the first 3 French cities which are stored in the document
descendant::country[./@name = "France"]/descendant-or-self::city[position() <= 3]/name/text()
7) Print all countries in which more than 60% of the population speak German
descendant::ethnicgroups[. = "German"][./@percentage > 60]/ancestor::country/@name
8) Print the average number of inhabitants of all cities in the document
sum(descendant::city/population) div count(descendant::city)
9) Print the names of all cities that have more than 20 characters
descendant::city/name[string-length(.) > 20]
10) How many tag names in the document have less than 3 characters?
Übung 4 XQuery
Exercise 1:
1) <A>100</A> + <B><C>1</C><C>1</C></B>
XQuery wertet "<B><C>1</C><C>1</C></B>" als rhs und "<A>100</A>" als lhs.
Deswegen wird "<B><C>1</C><C>1</C></B>" als 11 und "<A>100</A>" als 100 interpretiert.
lhs+rhs = 111
2) (1, 2) > (3, 2, 1)
true, da XQuery immer dann true zurück gibt, wenn der Vergleich mindestens zweier Objekte einer Sequenz true ergibt.
Hier: 2 > 1 -> true
3) ( ) != 1
Es existiert kein Element für das gilt rhs = lhs -> false
4) <a><a><a/></a></a>/descendant-or-self::a
XQuery geht in documentorder durch. Listet zuerst die descendandts und dann self
5) <xml><findme/></xml>[//findme]
Im Prädikat fehlt der Zugriff auf die document node, deswegen kommt ein Fehler.
Richt: <xml><findme/></xml>[.//findme]
Exercise 2:
1) Which countries can be found that have Jewish and Russian ethnic groups?
for $j in descendant::ethnicgroups
where $j = 'Russian' and $j/parent::country/@id =
(for $i in descendant::ethnicgroups
where $i = 'Jewish'
return $i/parent::country/@id)
return $j/parent::country/@name
oder
for $y in descendant::country
let $x := $y/ethnicgroups
where $x = "Russian" and $x = "Jewish"
return $y/@name
2) Create an alphabetically sorted list of all country names
for $y in descendant::country/@name
order by $y
return $y
3) Print the names and founding dates (@established attribute) of all organizations that have more than 180 members
for $y in descendant::organization
where count($y/member) > 180
return $y/@name | $y/@established
oder
for $y in descendant::organization
where count($y/member) > 180
return ($y/@name , $y/@established)
4) Create a list of all countries with the following syntax (whitespaces don’t matter):
<results>
<result name="Albania"/><result name="Andorra"/>...
<results>
<results>{
for $y in descendant::country
return <result>{$y/@name}</result>
}</results>
5) Guess you know that already, but... What’s the name of the country with the largest
population?
for $i in descendant::country
where $i/@population = max(descendant::country/@population)
return $i/@name
oder für bessere Performance:
let $y := max(descendant::country/@population)
for $i in descendant::country
where $i/@population = $y
return $i/@name
Assignment 9
Exercise 1: Starcase Join