{ for $b in doc("bib.xml")//book where count($b/author) > 0 return { $b/title } { for $a in $b/author[position()<=2] return $a } { if (count($b/author) > 2) then else () } }