In general, all built-in MarkLogic XQuery functions are available by default, 
you only need to declare the prefix with the correct namespace. For those that 
would require an xqy import, you can use <xdmp:import-module>

http://docs.marklogic.com/guide/xquery/xslt#id_60484

Docs on all functions:

http://docs.marklogic.com/all

Cheers,
Geert

From: 
<[email protected]<mailto:[email protected]>>
 on behalf of Bal Krishna Gupta 
<[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Monday, December 28, 2015 at 1:47 AM
To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] Passing in a MarkLogic map as an XSLT 
parameter

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]<mailto:[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]<mailto:[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