我一直在寻找一种使用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 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>谢谢!
发布于 2019-02-18 19:45:22
一种方法可能是创建一个名为expandXInclude.xqy的transformation,并在阅读时使用它。
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)
};https://stackoverflow.com/questions/54745700
复制相似问题