Я пытался загрузить преобразование xquery в базу данных модулей с помощью API Java Marklogic. Первоначально я использовал для загрузки преобразования Javascript (.sjs), используя тот же кусок кода, который работает нормально.
Теперь, когда я пытаюсь загрузить преобразование xquery с тем же кодом, оно не работает.
Моя трансформация Xquery:
xquery version "1.0-ml";
module namespace test =
"http://marklogic.com/rest-api/transform/deepan";
declare function test:transform(
$context as map:map,
$params as map:map,
$content as map:map
) as map:map*
{
let $jsoncont := xdmp:from-json-string($content)
let $inputval := "fname,lname"
let $orig-value := map:get($jsoncont, "value")
let $jscode := "var simple = require('/wdsUtils.sjs');
var content, input;
simple.createUri(content,input);"
let $uri := xdmp:javascript-eval($jscode,('content',$orig-value,'input',$inputval))
map:put($content, "uri",$uri)
map:put($content, "value",$orig-value)
return $content
};
Мой код Java для загрузки Преобразование:
private static final String TRANSFORM_NAME = "sec";
static String HOST = "localhost";
static int PORT = 8136;
static String USER = "admin";
static String PASSWORD = "admin";
private static DatabaseClient client =
DatabaseClientFactory.newClient(
HOST, PORT, new DigestAuthContext(USER, PASSWORD));
public static void loadLookup() throws FileNotFoundException
{
TransformExtensionsManager extensionsManager=client.newServerConfigManager().newTransformExtensionsManager();
FileInputStream fileInputStream=new FileInputStream("C:/Users/deepan/Desktop/sec.xqy");
//System.out.println(fileInputStream.toString());
InputStreamHandle handle=new InputStreamHandle(fileInputStream);
//extensionsManager.writeJavascriptTransform(TRANSFORM_NAME, handle);
extensionsManager.writeXQueryTransform(TRANSFORM_NAME, handle);
client.release();
}
Исключение:
Exception in thread "main" com.marklogic.client.FailedRequestException: Local message: config/transforms write failed: Bad Request. Server Message: RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: invalid sec extension: could not parse XQuery extension sec; please see the server error log for detail XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected Dollar_; sec either is not a valid module or does not provide extension functions (transform) in the http://marklogic.com/rest-api/transform/sec namespace
at com.marklogic.client.impl.OkHttpServices.putPostValueImpl(OkHttpServices.java:2890)
at com.marklogic.client.impl.OkHttpServices.putValue(OkHttpServices.java:2757)
at com.marklogic.client.impl.TransformExtensionsImpl.writeTransform(TransformExtensionsImpl.java:356)
at com.marklogic.client.impl.TransformExtensionsImpl.writeXQueryTransform(TransformExtensionsImpl.java:255)
at com.marklogic.client.impl.TransformExtensionsImpl.writeXQueryTransform(TransformExtensionsImpl.java:249)
at com.example.batch.Transform.loadLookup(Transform.java:33)
at com.example.batch.Transform.main(Transform.java:40)