This function iterates on the input sequence. It removes the pairs with the given keys from all objects and leaves non-objects intact.

declare function remove-keys($seq as item*, $keys as string*) as item*
  for $item in $seq
  return typeswitch ($item)
         case $object as object return
           for $key in keys($object)
           where every $to-remove in $keys satisfies $to-remove ne $key
           let $value := $object.$key
           return { $key : $value }
         default return $item

Example 189. Removing keys from an object (not implemented yet)

let $o := {
  "Captain" : "Kirk",
  "First Officer" : "Spock",
  "Engineer" : "Scott"
return remove-keys($o, ("Captain", "First Officer"))

Result (run with Zorba): An error was raised: "remove-keys": function with arity 2 not declared