requests concerning the map-module

Monday, 8 December 2014 · 2 messages
RS
Rob Stapper8 Dec 2014 10:45 #
Hi Christian, When processing XML-sources one is most probably going to need internal lookup-tables. The map-module in combination with closures;-) for its mapped data makes a great solution for this. However, the map-key just being just a single atomic value restricts its use or at least leads to some creativeness: - Sometimes one just needs a combined key instead of a single value key. My solution now is to convert the key-values to strings and concatenate them but this is no full-proof method. - Or, when processing XML-data, one wants the key to be an XML-element. For this I use a json-conversion, which works, but I still have to program the conversion. Both situations occur within my project. So, my request is to extend the map-key to allow multiple key-values and XML-elements. Well, now we're on it; why not allow closures as key-values. In that case we've our solution for the previous multiple key value request. How do you feel about this? Oh, now we're on the map-module; an update-function would be great. While processing XML-data one needs to update its lookup-tables often. I use the code below in a module. Maybe it's a candidate for an embedded map-module function.
declare function XQR.map:update
( $map as map(*) , $key as xs:anyAtomicType , $init.data as item() , $updateFunction as function(*) )
      {

        map:put( $map
, $key
                         , $updateFunction( let $go :=

                                                                 function(
$entry.data
)
{
if ( exists( $entry.data)) then $entry.data else $init.data }
                                                                return $go(
map:get( $map, $key))
) ) } ; Kind regards, Rob Stapper --- Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. http://www.avast.com
CG
Christian Grün8 Dec 2014 15:57 #
Hi Rob,
Quoted text · Rob Stapper · 1 line
> So, my request is to extend the map-key to allow multiple key-values and XML-elements.
General XQuery feature requests should probably go to the W3 Bugzilla tracker [1], as our intention is to stick as closely as possible to the official spec. I remember that the new issues this would bring along have been discussed before, so you may get more helpful feedback on that specific request by writing to the talk at x-query.com mailing list [2]. Hope this helps, Christian [1] https://www.w3.org/Bugs/Public/ [2] http://x-query.com/mailman/listinfo/talk
Quoted text · Rob Stapper · 71 lines
> > Well, now we’re on it; why not allow closures as key-values. In that case we’ve our solution for the previous multiple key value request. > > > > How do you feel about this? > > > > Oh, now we’re on the map-module; an update-function would be great. While processing XML-data one needs to update its lookup-tables often. > > I use the code below in a module. Maybe it’s a candidate for an embedded map-module function. > > > > declare function XQR.map:update > > ( $map as map(*) > > , $key as xs:anyAtomicType > > , $init.data as item() > > , $updateFunction as function(*) > > ) > > { > > map:put( $map > > , $key > > , $updateFunction( let $go := > > function( $entry.data > > ) > > { > > if ( exists( $entry.data)) > > then $entry.data > > else $init.data > > } > > return $go( map:get( $map, $key)) > > ) > > ) > > } ; > > > > Kind regards, > > Rob Stapper > > > > ________________________________ > > Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware. > www.avast.com > >

⚡Generated with XQuery