简体   繁体   English

如何在marklogic中使用xquery编写内容转换?

[英]How to write Content Transformations using xquery in marklogic?

I have a javascript function(.sjs) which will return a string. 我有一个javascript函数(.sjs),它将返回一个字符串。 Now, I've to write a xquery transformation which will be triggered through dmsdk. 现在,我将编写一个xquery转换,它将通过dmsdk触发。 Xquery function will accept a json doc, inside this transformation i need to trigger that javascript function which will return a string. Xquery函数将接受一个json doc,在这个转换中我需要触发那个将返回一个字符串的javascript函数。 Now, I need to use that string as a uri to load documents.. I've no idea on xquery!! 现在,我需要使用该字符串作为uri来加载文档..我不知道xquery !!

myXquery transformation function(jsonDoc)
{
/////////////////
myJavaScript function- which return a string
load the doc using this string as uri
}

Use Below query: 使用以下查询:

    declare namespace local ="local";

    declare function local:transformation($json-input, $json-uri as xs:string)
    {
    xdmp:save(concat("D:\", $json-uri), $json-input)(:Here I saved file on local path, If you want to save on Marklogic-DB use-: xdmp:document-insert( $json-uri, $json-input) :)

    };
    (:1:)
    let $input := '{"menu":{"id":"file", "value":"File"}}'
    for $json-input in $input
    (:2 Call here your Javascript function for json-uri :)
    let $json-uri :="json_first.json"

    return local:transformation(xdmp:unquote($json-input), $json-uri)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM