marklogic java client api expand xincludes

问题描述 投票:2回答:1

我正在寻找一种使用marklogic java client api扩展XML节点的方法,但是无法从api文档中找到有关此主题的任何信息。

示例xquery扩展xinclude节点:

import module namespace xinc = "http://marklogic.com/xinclude" at "/MarkLogic/xinclude/xinclude.xqy";
xinc:node-expand(fn:doc("http://my.app.org/contact/234"))

使用java client api XMLDocumentManager.read("http://my.app.org/contact/234")从marklogic数据库读取文档时,是否可以进行“node-expand”?

样本文件:

<contact>
    <photo>
        <xi:include href="http://my.app.org/files/123" xpointer="xpath(//file/content/text())" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
    </photo>
</contact>

谢谢!

marklogic marklogic-8
1个回答
3
投票

一种方法可能是创建一个名为transformationexpandXInclude.xqy并在阅读时使用它。

XMLDocumentManager.read("http://my.app.org/contact/234", new DOMHandle(), new ServerTransform("expandXInclude.xqy"));

可以使用ml-gradle创建和部署转换。查看基本示例here。转换可能就像这样简单:

xquery version "1.0-ml";

module namespace transform = "http://marklogic.com/rest-api/transform/sample";
import module namespace xinc = "http://marklogic.com/xinclude" at "/MarkLogic/xinclude/xinclude.xqy";

declare function transform(
        $context as map:map,
        $params as map:map,
        $content as document-node()
) as document-node()
{
    xinc:node-expand($content)
};
© www.soinside.com 2019 - 2024. All rights reserved.