1

I am trying to load a transformation to the marklogic database but it fails resulting in "either is not a valid module or does not provide extension functions (transform) in the http://marklogic.com/rest-api/transform/validate namespace".

My xqy file is below:

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;
};

I am running the following command:

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

And the error that I am seeing is: HTTP/1.1 400 Bad Request Content-type: application/json; charset=UTF-8 Server: MarkLogic Content-Length: 557 Connection: Keep-Alive 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]

I appreciate any help in solving this issue.

1 Answer 1

4

Just drop the semicolon after your return $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
};
Sign up to request clarification or add additional context in comments.

2 Comments

I had a similiar post, but deleted it because this on came in just before me. To be clear, ML will not load files with syntax errors. The response from the rest api as well as ML Error Logs are your friend. Although a bit vague, it still tells you that your code itself is broken - giving you somewhere to look.
You can get a full stacktrace from the REST API by going to Groups - Default in the Admin app and cranking up "file log level" to "debug".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.