xsl-list
[Top] [All Lists]

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

2022-01-07 11:45:48
Christian and Jean-Paul,

 

I hadn’t thought about map:for-each() (not sure I even realized it was an 
option).

 

I’ll have to think about that more.

 

Map:for-each()  feels very familiar to my JavaScript brain (which it pains me 
to admit I even have but there it is).

 

I’ll check out Joe’s book...

 

Cheers,

 

E.

 

--

Eliot Kimber

http://contrext.com

 

 

 

From: "Christian Grün christian(_dot_)gruen(_at_)gmail(_dot_)com" 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>
Reply-To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Date: Friday, January 7, 2022 at 11:21 AM
To: xsl-list <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: Re: [xsl] Subtle (or not?) Map Processing Bug in XQuery

 

Hi Eliot,

 

I’m also wondering if there’s any general source of XQuery coding patterns for 
working with maps in non-trivial ways? I haven’t run across one but I haven’t 
looked too hard yet.

 

You could use map:remove, either with map:keys…

 

let $orphanMap := map:remove($imageMap,

  map:keys($imageMap)[not(local:notReferenced($imageMap(.)('keyname')))]

)

 

…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-filter

[2] https://github.com/qt4cg/qtspecs/issues/29



 

 

 
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>