Re: [xsl] Subtle (or not?) Map Processing Bug in XQuery

Subject: Re: [xsl] Subtle (or not?) Map Processing Bug in XQuery
From: "Christian Grün christian.gruen@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 7 Jan 2022 17:21:35 -0000
Hi Eliot,

> Ibm also wondering if therebs any general source of XQuery coding
patterns for working with maps in non-trivial ways? I havenbt run across one
but I havenbt looked too hard yet.

You could use map:remove, either with map:keysb&

let $orphanMap := map:remove($imageMap,
  map:keys($imageMap)[not(local:notReferenced($imageMap(.)('keyname')))]
)

b&or in combination with map:for-each:

let $orphanMap := map:remove($imageMap,
  map:for-each($imageMap, function($k, $v) {
    if(local:notReferenced($v('keyname'))) then () else $k
  })
)

XQuery 4.0 will probably include a map:filter function [1] and,
possibly, additional functions for iterating over the entries of a map
[2].

Hope this helps,
Christian

[1]
https://qt4cg.org/branch/master/xpath-functions-40/Overview.html#func-map-fil
ter
[2] https://github.com/qt4cg/qtspecs/issues/29

Current Thread