MarkLogic-mlcp导出到单个输出文件

时间:2019-02-10 21:31:10

标签: marklogic marklogic-9 mlcp

MarkLogic 9.0-6.2版

mlcp版本9.0.6

我有一个客户集合,每个文档都有一个客户根节点,如下所示。

<customer>
  <customerId>123</customerId>
  ....
</customer>

我需要将集合中的所有文档导出到一个新的名为customerinfo的根目录下的单个输出文件中

<customerInfo>
    <customer>
      <customerId>123</customerId>
      ....
    </customer>
    <customer>
      <customerId>456</customerId>
      ....
    </customer>
</customerInfo>

使用以下代码,我可以将集合导出为目录下的单个文档。

mlcp.sh export -ssl \
-host localhost \
-port 8010 \
-username uname \
-password pword \
-mode local \
-output_file_path /test/TestFiles/customer \
-collection_filter customer \
-output_type document

是否可以将输出汇总到一个新的根节点下的单个文档中?

2 个答案:

答案 0 :(得分:0)

不。 mlcp可以在导入期间转换文档,但不能在导出期间转换文档。不过,在XQuery中将查询结果合并到一个文档中非常简单,

xdmp:save('/test/TestFiles/customer/merged.xml',
  <root>{ collection('customer') }</root>
)

您还可以研究其他corbData Movement SDK等MarkLogic工具。

答案 1 :(得分:0)

ml-gradle的某些任务使用MarkLogic的Data Movement SDK,因此理想情况下您无需编写任何代码即可-https://github.com/marklogic-community/ml-gradle/wiki/Exporting-data