Changed the query to xQuery so it is able to cope with entire collections instead of just iterating over separate XML documents