运行 来自 Marklogic 主模块的库模块?

Run a library Module from Main Module in Marklogic?

更新代码

我的图书馆模块是这样的

   module namespace test="http://try.marklogic.com/test";
declare function test:median(
  $map as map:map*
) as node()*
{
cts:search(fn:doc(),
  cts:and-query((
  cts:element-word-query(
      xs:QName("College"),map:get($map,"College")),
  cts:element-word-query(
      xs:QName("Year"),map:get($map,"Year")),
   cts:element-word-query(
      xs:QName("Dep"),map:get($map,"Dep")),
   cts:element-word-query(
      xs:QName("Grade"),map:get($map,"Grade")),
   cts:element-range-query(xs:QName("Date"), ">",
      map:get($map,"StartDate")),
   cts:element-range-query(xs:QName("Date"), "<",
      map:get($map,"EndDate")))))
};

我的主模块是这样的

import module namespace test = "http://try.marklogic.com/test" at "/lib1.xqy";

let $map := map:map()
let $College := "UCLA"
let $Year := "2000"
let $StartDate := xs:date("2017-01-06")
let $EndDate := xs:date("2018-01-06")
let $Dep := "CSE"
let $Grade := "A"
let $put := ( map:put($map, "College",$College),
            map:put($map, "Year",$Year),
            map:put($map, "Date",$StartDate),
            map:put($map, "Date",$EndDate),
            map:put($map, "Dep",$Dep),
            map:put($map, "Grade",$Grade) )
return test:median($map)

如何单独传递参数而不是在主模块中指定?

删除库中的“as cts:search”第 4 行。

如果您需要定义 return 类型(从语言的角度来看您不需要),那么使用您实际 returning 的 return 类型。 那将是 cts:search() 结果 ,“as node()*

参见:https://docs.marklogic.com/cts:search