{ let $A := doc("..\..\..\examples\sourceA.xml")/sourceA return $A/* union ( let $B := doc("..\..\..\examples\sourceB.xml")/sourceB for $titleB in distinct-values($B//title) let $dirB := $B//movie[title=$titleB]/director where not(exists( for $A in doc("..\..\..\examples\sourceA.xml")/sourceA for $titleA in $A//title where $titleA = $titleB return $titleA )) return {$titleB} {$dirB[1]} { for $actB in $B/actor where $actB//movie/title = $titleB return {data($actB/name)} } ) }