【问题标题】:marklogic java client api expand xincludesmarklogic java客户端api扩展xincludes
【发布时间】:2019-02-18 10:57:05
【问题描述】:

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

扩展 xinclude 节点的示例 xquery:

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 客户端 api XMLDocumentManager.read("http://my.app.org/contact/234") 从 marklogic 数据库读取文档时是否可以进行“节点扩展”?

示例文档:

<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】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-07
      • 2017-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-28
      相关资源
      最近更新 更多