在MarkLogic Server中安装转换

时间:2016-10-11 21:44:32

标签: marklogic

我正在尝试将转换加载到marklogic数据库但它失败导致“要么不是有效模块,要么在http://marklogic.com/rest-api/transform/validate命名空间中不提供扩展函数(转换)”。

我的xqy文件如下:

xquery version "1.0-ml";
module namespace trans = "http://marklogic.com/rest-api/transform/validate";
declare function trans:transform(
    $context as map:map,
    $params as map:map,
    $content as document-node()
) as document-node()
{
    let $validate := validate strict { $content }
    return $content;
};

我正在运行以下命令:

curl --anyauth --user admin:admin -X PUT -d@"./filetype_xform.xqy" -i -H "Content-type: application/xquery" 'http://localhost:8061/v1/config/transforms/validate'

我看到的错误是:     HTTP / 1.1 400错误请求     内容类型:application / json;字符集= UTF-8     服务器:MarkLogic     内容长度:557     连接:保持活力     Keep-Alive:timeout = 5

{"errorResponse":{"statusCode":400, "status":"Bad Request", "messageCode":"RESTAPI-INVALIDCONTENT", "message":"RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: invalid validate extension: could not parse XQuery extension validate; please see the server error log for detail XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected Rbrace_, expecting Function30_ or Percent_; validate either is not a valid module or does not provide extension functions (transform) in the http://marklogic.com/rest-api/transform/validate namespace"}}[admin@localhost transformations]

我感谢您解决此问题的任何帮助。

1 个答案:

答案 0 :(得分:4)

返回$ content后,只需删除分号:

xquery version "1.0-ml";
module namespace trans = "http://marklogic.com/rest-api/transform/validate";
declare function trans:transform(
    $context as map:map,
    $params as map:map,
    $content as document-node()
) as document-node()
{
    let $validate := validate strict { $content }
    return $content
};