2. XPath
a) //continent
//continent/name/text()
/mondial/continent/name/text()
b) //country[border/@country='D']/name/text()
c) //country[count(ethnicgroups)>10]/name/text()
d) //island[located/@country='GB']/name/text()
3. XQuery
a)
for $c in doc("mondial.xml")//country
order by number($c/@area) descending
return $c/name/text()
b)
{
for $c in doc("mondial.xml")//country
return {$c/name/text()}
}
c) self-join
for $c1 in doc("mondial.xml")//country
for $c2 in doc("mondial.xml")//country
where $c1/@car_code=$c2/border/@country
return {$c1/name/text()} - {$c2/name/text() }
-> without duplicates
for $c1 in doc("mondial.xml")//country
for $c2 in doc("mondial.xml")//country
where $c1/@car_code=$c2/border/@country
and $c1/name < $c2/name
return {$c1/name/text()} - {$c2/name/text() }
d) join of 2 documents
for $c in doc('mondial.xml')//country
for $s in doc('hamlet.xml')//*
where contains($s/text(),$c/name/text())
return
{$c/name/text()}
{$s}