[xquery-talk] Manipulating Maps In Non-Trivial Ways

Eliot Kimber ekimber at contrext.com
Mon Jul 20 11:44:21 PDT 2015


Hmm, I'll have to think about that one.

In the context of XQuery I don't see how it's different from a FOR
expression inside map:merge(). In XSLT I can see the value because you
might be applying templates or something else you can't do directly in an
XPath expression.

Cheers,

Eliot
----
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com




On 7/20/15, 1:35 PM, "Michael Kay" <mike at saxonica.com> wrote:

>
>> On 19 Jul 2015, at 22:55, Eliot Kimber <ekimber at contrext.com> wrote:
>> 
>> Yes, the fold operations are still a bit too clever for my taste--I
>>prefer
>> to make my business a logic a little more verbose to clearer, at least
>>to
>> me--I don't want to have to think too deeply when I'm programming :-)
>> 
>
>Although I say it myself, I think the xsl:iterate instruction in XSLT
>3.0, which is essentially syntactic sugar over a fold operation,
>addresses the readability problem quite well:
>
>> $newKeys => fold-left($m1, function($key, $map) { $map => map:put($key,
>> ($map($key), $obj) })
>
>becomes
>
><xsl:iterate select=³$newKeys²>
>  <xsl:param name=³map² select=³$m1²/>
>  <xsl:on-completion select=³$map²/>
>  <xsl:next-iteration>
>    <xsl:with-param name=³map² select=³map:put($map, ., ($map(.),
>$obj))²/>
>  </xsl:next-iteration>
></xsl:iterate>
>
>Michael Kay
>Saxonica
>
>





More information about the talk mailing list