This is the second question related to MarkLogic content pump utility.
I am ingesting a single aggregated XML document with multiple records into MarkLogic Content pump. I expect the the aggregate XML document to be transformed to a different format and also the content pump utility to generate multiple xml document from a single input large xml document.?
Example: Aggregated input xml document:
<root>
<data>Bob</data>
<data>Vishal></data>
</root>
Expected Output from content pump : Two documents with a different format:
Document 1 :
<data1>Bob</data1>
Document 2
<data1>Vishal</data1>
I am using following XSLT to split the above document into two nodes:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="root">
<xsl:apply-templates select="data"></xsl:apply-templates>
</xsl:template>
<xsl:template match="data">
<data1><xsl:value-of select="."/></data1>
</xsl:template>
</xsl:stylesheet>
output:
<?xml version="1.0" encoding="UTF-8"?>
<data1>Bob</data1>
<data1>Vishal</data1>
Following is the XQuery transform, which calls the above the "XSLT file" to generate two nodes:
xquery version "1.0-ml";
module namespace example = "http://marklogic.com/example";
declare function example:transform(
$content as map:map,
$context as map:map
) as map:map*
{
let $attr-value :=
(map:get($context, "transform_param"), "UNDEFINED")[1]
let $the-doc := map:get($content, "value")
let $let-output:= xdmp:xslt-invoke("/marklogic.rest.transform/simple-xsl/assets/transform.xsl", $the-doc )
return (map:put(
$content, "value",
$let-output
),$content)
};
The above XQuery transforms fails and returns a error. So, how do I modify the above XQuery program so that it generates and indexes multiple transformed XML documents from a single document?
MLCP Command:
mlcp.sh import -host localhost -port 8040 \
-username admin -password admin \
-input_file_path ./parent-form.xml \
-transform_module /example/parent-transform.xqy \
-transform_namespace "http://marklogic.com/example" \
-transform_param "my-value" \
-output_collections people \
-output_permissions my-app-role,read,my-app-role,update