1 {//titre[../@numero<=3]} 2 {//titre[ancestor::serie/@nom="Lanfeust de Troy"]} 3 {for $f in //title return {$f/text()}} 4 {for $p in distinct-values(//SPEAKER/text()) return {$p/text()}} 5 {for $p in distinct-values(//SPEAKER/text()) where //ACT[TITLE/text()="ACT I"]//SPEAKER/text() = $p return {$p}} 6 {for $p in distinct-values(//SPEAKER/text()) let $lines := //LINE[../SPEAKER/text()=$p] return {$p}} 7 {for $p in distinct-values(//SPEAKER/text()) where not(//PERSONA/text() = $p) return {$p}} 8 declare function local:tr-film($f) { let $rt := $f/ancestor-or-self::document-node() return {$f/titre} {$f/annee} {for $r in $f/realisateur return {$rt//personne[@id=$r/@ref]/nom/text()}} {for $s in $f/scenariste return {$rt//personne[@id=$s/@ref]/nom/text()}} {for $s in $f/star return {$rt//personne[@id=$s/@ref]/nom/text()}} }; local:tr-film(/films/film[1]) 9 declare function local:tr-film($f) { let $rt := $f/ancestor-or-self::document-node() return {$f/titre} {$f/annee} {for $r in $f/realisateur return {$rt//personne[@id=$r/@ref]/nom/text()}} {for $s in $f/scenariste return {$rt//personne[@id=$s/@ref]/nom/text()}} {for $s in $f/star return {$rt//personne[@id=$s/@ref]/nom/text()}} }; {for $f in //film[realisateur/@ref = star/@ref] return local:tr-film($f)} 10 declare function local:tr-film($f) { let $rt := $f/ancestor-or-self::document-node() return {$f/titre} {$f/annee} {for $r in $f/realisateur return {$rt//personne[@id=$r/@ref]/nom/text()}} {for $s in $f/scenariste return {$rt//personne[@id=$s/@ref]/nom/text()}} {for $s in $f/star return {$rt//personne[@id=$s/@ref]/nom/text()}} }; declare function local:html-film($f) {

{$f/titre/text()}{if ($f/annee) then (" (",$f/annee/text(),")") else ()}

, (if ($f/realisateur) then (

Realisateur(s)

, ) else () ) , (if ($f/scenariste) then (

Scenariste(s)

, ) else () ) , (if ($f/acteur) then (

Acteur(s)/Actrice(s)

, ) else () ) }; Des films {for $f in //film let $f2 := local:tr-film($f) order by $f/annee, $f/titre return local:html-film($f2)}