代码之家  ›  专栏  ›  技术社区  ›  Private

从Marklogic中的主模块运行库模块?

  •  1
  • Private  · 技术社区  · 7 年前

    更新的代码

    我的库模块是这样的

       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)
    

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

    1 回复  |  直到 7 年前
        1
  •  2
  •   Mads Hansen    7 年前

    摆脱“ as cts:search “库中的第4行。

    如果您需要定义一个返回类型(从语言的角度来看不需要),那么使用实际返回的返回类型。 那就是 后果 属于 cts:search() , " as node()* "

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