Deep map replacements

Hi everyone,

One new standard function I would appreciate having would be a 4arity
version of map:put(): map:put($map as *map(*)*,  $key as xs:anyAtomicType,
$value as item()* , $apply-deeply as *xs:boolean*) as *map(*)*.

The operation would be the same except with the option of being applied
deeply.

Why? map:put() applies to top-level map entries only, but fn:transform(),
which I'm now using extensively, makes a deeper reach desirable. The latter
asks for a map with deep maps for static parameters, stylesheet parameters,
etc. Often I need to change the parameter options, and therefore the deeper
maps, fed to fn:transform() based upon what type of input is being handled.
My working version of 4arity map:put() has saved me a lot of time and
hassle, and has let me approach the task of building maps for fn:transform() in
a modular fashion.

Originally I thought about  map:replace($map as *map(*)*,  $replacement as
map(*) , $apply-deeply as *xs:boolean*) as *map(*)* )  Every map entry in
$input would be replaced by a top-level map entry in $replacement if the
keys match. That's the version that I find most convenient, because I would
rather simply build a map, and not have to iterate over each map entry.

Just an idea, perhaps a bad one.

jk
-- 
Joel Kalvesmaki
kalvesmaki.com

Received on Monday, 30 November 2020 05:16:45 UTC