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.
www.avast.com