Exactly what I needed. Thanks BK!

-David

On Sun, Dec 27, 2015 at 7:47 PM, Bal Krishna Gupta <[email protected]>
wrote:

> Hi David,
>
> Below is the code to list all the key values pairs. Please let me know if
> you have any questions.
>
> xquery version "1.0-ml";
>
> let $items := map:map()
> let $_ := map:put($items, "Car", "$5,300")
> let $_ := map:put($items, "Boat", "$23,740")
>
> let $params := map:map()
> let $_ := map:put($params, "title", "Items sold")
> let $_ := map:put($params, "items", $items)
>
> let $xsl := <xsl:stylesheet xmlns:xsl="
> http://www.w3.org/1999/XSL/Transform";
>       xmlns:map="http://marklogic.com/xdmp/map";
>       version="2.0">
>     <xsl:param name="title"/>
>     <xsl:param name="items" as="map:map"/>
>     <xsl:template match="/">
>        <Report>
>          <title><xsl:value-of select="$title" /></title>
>
>          <xsl:for-each select="map:keys($items)">
>            <item>
>              <Name> <xsl:value-of select="."/> </Name>
>              <Value> <xsl:value-of select="map:get($items, .)"/> </Value>
>            </item>
>          </xsl:for-each>
>        </Report>
>     </xsl:template>
>   </xsl:stylesheet>
> return
>   xdmp:xslt-eval($xsl, document { <foo></foo> }, $params)
>
> Thanks
> BK
>
> On Sun, Dec 27, 2015 at 6:08 PM, David Strickland <[email protected]>
> wrote:
>
>> I'm new to XQuery/XPath/XSLT and MarkLogic, so it's totally possible that
>> I'm missing something basic :)
>>
>> I would like to pass in a set of name/value pairs (i.e. a map) as a
>> single named parameter in an XSLT transformation. There could be zero or
>> more name/value pairs. Something similar to the following (XQuery comments
>> would need to be replaced) ...
>>
>> <snip>
>> xquery version "1.0-ml";
>>
>> let $items := map:map()
>> let $_ := map:put($items, "Car", "$5,300")
>> let $_ := map:put($items, "Boat", "$23,740")
>>
>> let $params := map:map()
>> let $_ := map:put($params, "title", "Items sold")
>> let $_ := map:put($params, "items", $items)
>>
>> let $xsl := <xsl:stylesheet xmlns:xsl="
>> http://www.w3.org/1999/XSL/Transform";
>>       xmlns:map="http://marklogic.com/xdmp/map";
>>       version="2.0">
>>     <xsl:param name="title"/>
>>     <xsl:param name="items" as="map:map"/>
>>     <xsl:template match="/">
>>        <Report>
>>          <title><xsl:value-of select="$title" /></title>
>>          (: for each entry in $items :)
>>            <Item>
>>              <Name>(: entry key :)</Name>
>>              <Value>(: entry value :)</Value>
>>            </Item>
>>          (: /////////////////////// :)
>>        </Report>
>>     </xsl:template>
>>   </xsl:stylesheet>
>>
>> return
>>   xdmp:xslt-eval($xsl, document { <foo></foo> }, $params)
>> </snip>
>>
>> Looking through the mailing list archive I see that a similar question
>> was asked: http://markmail.org/message/d6lj35jvtunnxdmt
>>
>> Someone replied in the thread saying that "You could pass a map as the
>> value of any variable", but doesn't give the syntax.
>>
>> Any guidance would be much appreciated.
>> -David
>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> Manage your subscription at:
>> http://developer.marklogic.com/mailman/listinfo/general
>>
>>
>
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to