let $ms := doc("movies_alone.xml")/movies/movie,
$as := doc("artists_alone.xml")/artists/artist
return
Movies
{
for $m in $ms
where count($m/actor) >= 2
return - {
{string($m/title)}, " with:",
{
for $a in $as
where $a/@id = $m/actor[2>=position()]/@id
return - {
string($a/first_name), string($a/last_name), "as",
string($m/actor[@id=$a/@id]/@role)
}
,
if (count($m/actor) > 2) then - ...
else ()
}
}
}