ML Gradle Export to File doesn't provide a way to export header and body in a single XML payload
I tried to export the body using the following,
gradle mlExportToFile -PwhereUriPattern=*.xml -PexportPath=c:\export\export.xml -PfileHeader="<results>" -PfileFooter="</results>"
The above export gradle export statement gets me the following result,
<results>
<customer id="1">
.
.
</customer>
<customer id="2">
.
.
</customer>
</results>
However, I expect the output to be,
<results>
**<TransactionRequestDt>2019-15-02T13:22:01</TransactionRequestDt>
<VersionCd>1.0</VersionCd>
<RequestorSystemCd>05</RequestorSystemCd>**
<body>
<customer id="1">
.
.
</customer>
<customer id="2">
.
.
</customer>
<body>
</results>
TransactionRequestDt, VersionCd & RequestorSystemCd are coming from a different document structure. Is there a way to combine the results while exporting using gradle export task?
As noted in the docs at https://github.com/marklogic-community/ml-gradle/wiki/Exporting-data#exporting-data-to-a-file , mlExportToFile grabs all documents returned by a query and writes them to a single file, and you can include an optional header and/or footer. And it's using the Data Movement SDK - http://docs.marklogic.com/guide/java/data-movement - to do so.
Based on your expectations, it looks like you want to query for additional data and write it near the top of the document. You'd need to write your own export code using DMSDK to do that. It would be something like - write the the root element to a file; query for the 3 elements you have listed and write them to the file; write a "body" tag to the file; then use DMSDK with ExportToWriterListener to write every document returned by a query to the file; then write the closing "body" and "results" tags.