LET $x := document("input.xml")//xref[@xrefid = "top4"], $t := document("input.xml")//title BEFORE $x RETURN $t[last()]