Regarding below response, if I apply -aggregate_record_element, then the input 
aggregate document will be split and then will sent to xquery transform. I want 
the the aggregate document to be sent to transform “as is” and the xquery and 
xslt combination to split the document into multiple xml document. Because I 
have scenario like this

Input document 1
<solar-system>
        <shared_attribute>water</shared_attribute>
        <planet>earth</planet>
        <planet>mars</planet>
</solar-system>

Output (multiple document>
Document 1:
   <plant exists=“water>earth</planet>
    
Document 2:
  <plant exists=“water>earth</planet>   

How to achieve above through Content Pump xquery->xslt transform? If I use 
-aggregate_record_element, the shared-attribute will be lost. That’s why I 
created xslt which manually splits the document and returns two node to xquery 
program. As the the MarkLogic document

Please refer to below link:
 docs.marklogic.com/guide/ingestion/content-pump#id_82518 
<https://docs.marklogic.com/guide/ingestion/content-pump#id_82518>.
 It clearly says below (but example not provided):

 Creating a Custom Transformation :
A custom transformation is an XQuery function module that conforms to the 
following interface. Your function receives a single input document, described 
by $content, and can generate zero, one, or many output documents. –




Response: 

You'll probably want mlcp to split the aggregate file using
-aggregate_record_element.  See:

    https://docs.marklogic.com/guide/ingestion/content-pump#id_65814


I believe the transform will then be applied to each new document created
by the split, so at the level of the data node in your example.




Question:
This is the second question related to MarkLogic content pump utility. 
Question: 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 documents 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>

XSLT 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 to modify above 
xquery program so that it generates and indexes multiple            transformed 
xml document from a single document?


MLCP command used in below scenario
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




_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to