Hi Matt,

MLCP will already call the transform for each document separately, so you don’t 
need the for loops. Use something like let $p := map:get($content, "value") 
instead. I also think you don’t really need to rewrite the uri, but maybe you 
prefer different uri’s as well.

About what is actually going wrong: for each document MLCP will be processing 
fadperson docs 1 to 100, and updating the $content map:map with ultimately the 
uri and contents of only the last fadperson result. You will end up with just 
one new file in the final database if I read this correctly..

Cheers,
Geert

PS: collection() already returns documents, do you don’t need to use 
doc(base-uri()) on its output either..

From: 
<[email protected]<mailto:[email protected]>>
 on behalf of Matet Layosa <[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Wednesday, October 14, 2015 at 9:01 AM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] MLCP content transformation between database 
during ingestion not working

Hi there! I am just new to Marklogic/Xquery and is currently working on a 
project where I need to transform the files from an existing database with 
millions of xml documents, change each files' document structure while 
ingesting it to another database.
So far, I have this transform module:

xquery version "1.0-ml";
module namespace master-person = "http://marklogic.com/ofis/masterperson";;
declare namespace fad = "http://marklogic.com/ofis/fad";;

declare variable $person := /fad:fadperson;

declare function master-person:transform(
  $content as map:map,
  $context as map:map
) as map:map*
{
 for $docs in fn:collection("fadperson") [1 to 100]
  for $p in fn:doc(fn:base-uri($docs))/fad:fadperson
(:  let $map := map:map() :)
  let $id := $p/fad:id/fn:string()
  let $profile :=
          <person>
            <id>{$p/fad:id/fn:string()}</id>
            <name>
              <firstname>{$p/fad:first_name/fn:string()}</firstname>
              <lastname>{$p/fad:last_name/fn:string()}</lastname>
              <middlename>{$p/fad:last_name/fn:string()}</middlename>
              <nameextension>{$p/fad:name_extension/fn:string()}</nameextension>
              <othername>{$p/fad:other_name/fn:string()}</othername>
            </name>
            <gender>{$p/fad:gender/fn:string()}</gender>
            <civilstatus>{$p/fad:civil_status/fn:string()}</civilstatus>
            <birthdate>{$p/fad:birthdate/fn:string()}</birthdate>
            <birthplace>{$p/fad:birthplace/fn:string()}</birthplace>
         </person>
 return
    (
      map:put($content, "uri", fn:concat("/fadperson/", $id, ".xml"))
      ,
      map:put($content, "value", document { $profile })
      ,
      $content
    )

};

I also have installed this in my current XDBC server:
xquery version "1.0-ml";
xdmp:document-load("/home/jema/Marklogic/apps/data-transform/transform-person.xqy",
    <options xmlns="xdmp:document-load">
        <uri>/data/transform-person.xqy</uri>
      <repair>none</repair>
      <permissions>{xdmp:default-permissions()}</permissions>
    </options>)

Then I execute this on terminal:
 mlcp.sh copy -mode local -input_host localhost -input_port 8004 
-input_username fad-admin -input_password f4d123 -output_host localhost 
-output_port 8041 -output_username fad-admin -input_password f4d123 
-collection_filter 'fadperson' -transform_module /data/transform-person.xqy 
-transform_namespace "http://marklogic.com/ofis/masterperson";

the input_port: 8004 = contains the files for transformation;
output_port:8041 = where the transformed files must be ingested

It doesn't output anything. Neither an error is showing up. It reached 100% 
complete yet no files loaded to the database.
What am I missing here? Is my transform module code not creating a document?


Thanks!

Matt
[email protected]<mailto:[email protected]>


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

Reply via email to