我正在尝试使用 2 层服务器端 javascript 应用程序返回 JSON 格式的 XML 文档。我知道 MarkLogic 可以使用 REST api 在 JSON 和 XML 格式之间轻松切换。
但是,以下返回 xml:
cts.search('something', ['format-xml']) // options may be omitted
但这什么也没返回:
cts.search('something', ['format-json'])
根据文档,我认为我已经正确使用了该功能。
这可以使用服务器端javascript吗?
更新:
使用transformToJsonObject
如下:
var json = require('/MarkLogic/json/json.xqy');
var doc = fn.doc('/content/rss/72eb9bf835521446be8d2176e1ac9d22.xml')
var jsonDoc = json.transformToJsonObject(doc, json.config('custom'));
jsonDoc
我收到以下错误:
500 Internal Server Error
XDMP-STACKOVERFLOW: Stack overflow
in /MarkLogic/json/custom.xqy, at 493:23,
in json-custom:is-ignore-attribute#2(json:object(<json:object xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:json="http://marklogic.com/xdmp/json"><json:entry key="element-qname-from-json-name"><json:value xsi:t...</json:object>...XDMP-ATOMIZEFUNC: (err:FOTY0013) Functions cannot be atomized...), fn:doc("/content/rss/72eb9bf835521446be8d2176e1ac9d22.xml")/newsitem/article/*:html/*:head/*:script[5]/*:script/*:script/*:script/*:link/*:script/*:script/*:script/*:script/*:script/*:script/*:style/*:script/*:script/*:script/*:script/*:script/*:script/*:script/*:script/*:script/*:script/*:link/*:script/*:script/*:noscript/*:link/*:meta/*:body/*:div/*:div/*:div/*:script/*:div/*:div/*:script/*:script/*:div/*:div/*:script/*:script/*:script/*:script/*:noscript/*:p/*:header/*:div/*:div/*:div/*:a/*:section/*:div/*:h2/*:ul/*:li/*:a/*:li/*:a/*:div/*:div/*:a/*:img/*:span/*:script/*:nav/*:div/*:h2/*:ul/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:li/*:a/*:span/*:div/*:a/*:form/*:div/*:label/*:div/*:script/*:div/*:div/*:div/*:div/*:div/*:a/*:svg/*:title/*:h2/*:a/*:div/*:button/*:div/*:ul/*:li/*:a/*:span/*:li/*:a/*:span/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:div/*:nav/*:a/*:span/*:span/*:ul/*:li/*:a/*:span/*:li/*:a/*:span/*:span/*:div/*:div/*:script/*:script/*:div/*:div/*:span/*:span/*:a/*:div/*:div/*:script/*:script/*:div/*:div/*:div/*:span/*:span/*:a/*:div/*:div/*:script/*:script/*:div/*:div/*:div/*:div/*:h1/*:div/*:ul/*:li/*:div/*:li/*:span/*:a/*:div/*:figure/*:span/*:img/*:span/*:span/*:figcaption/*:span/*:span/*:p/*:p/*:p/*:p/*:p/*:div/*:div/*:script/*:script/*:h2/*:p/*:p/*:figure/*:span/*:div/*:span/*:span/*:figcaption/*:span/*:span/*:p/*:p/*:p/*:p/*:p/*:p/*:p/*:p/*:div/*:a/*:h2/*:a/*:ul/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:li/*:a/*:span/*:div/*:div/*:div/*:h2/*:div/*:ul/*:li/*:a/*:div/*:div/*:div/*:span/*:div/*:div/*:li/*:a/*:div/*:div/*:div/*:span/*:div/*:div/*:li/*:a/*:div/*:div/*:div/*:span/*:div/*:div/*:li/*:a/*:div/*:div/*:div/*:span/*:div/*:div/*:li/*:a/*:div/*:div/*:div/*:span/*:div/*:div/*:li/*:a/*:div/*:div/*:div/*:span/*:div/*:div/*:li/*:a/*:div/*:div/*:div/*:span/*:div/*:div/*:li/*:a/*:div/*:div/*:div/*:span/*:div/*:div/*:li/*:a/*:div/*:div/*:div/*:span/*:div/*:div/*:div/*:div/*:div/*:h2/*:div/*:ul/*:li/*:div/*:div/*:a/*:div/*:span/*:p/*:div/*:div/*:div/*:div/*:script/*:script/*:div/*:div/*:script/*:script/*:div/*:div/*:script/*:script/*:div/*:div/*:h2/*:a/*:strong/*:p/*:div/*:a/*:strong/*:div/*:a/*:strong/*:div/*:div/*:div/*:script/*:script/*:div/*:div/*:h2/*:div/*:div/*:a/*:div/*:div/*:div/*:h3/*:p/*:div/*:a/*:div/*:div/*:div/*:h3/*:p/*:div/*:a/*:div/*:div/*:div/*:h3/*:p/*:div/*:a/*:div/*:div/*:div/*:h3/*:p/*:div/*:a/*:div/*:div/*:div/*:h3/*:p/*:div/*:a/*:div/*:div/*:div/*:h3/*:p/*:div/*:a/*:div/*:div/*:div/*:h3/*:p/*:div/*:a/*:div/*:div/*:div/*:div/*:div/*:span/*:span/*:span/*:h3/@class) [1.0-ml]
$config = json:object(<json:object xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:json="http://marklogic.com/xdmp/json"><json:entry key="element-qname-from-json-name"><json:value xsi:t...</json:object>...XDMP-ATOMIZEFUNC: (err:FOTY0013) Functions cannot be atomized...)
$a = fn:doc("/content/rss/72eb9bf835521446be8d2176e1ac9d22.xml")/newsitem/article/*:html/*:head/*:script[5]/*:script/*:script/*:script/*:link/*:script/*:script/*:script/*:script/*:script/*:script/*:style/*:script/*:script/*:script/*:script/*:scr