This function returns the intersection of the supplied objects, and aggregates values corresponding to the same name into an array. Non-objects are ignored.
declare function intersect($seq as item*) { {| let $objects := $seq[. instance of object()] for $key in keys(head($objects)) where every $object in tail($objects) satisfies exists(index-of(keys($object), $key)) return { $key : $objects.$key } |} };