Apply the Transformation
To ingest the sample documents and apply the previously installed transformation, use a command similar to the following. Change the username
, password
, host
, port
, and input_file_path
options to match your environment.
Use a command similar to the following if you installed the XQuery transform module:
# Windows users, see Modifying the Example Commands for Windows $ mlcp.sh import -mode local -host mlhost -port 8000 \ -username user -password password \ -input_file_path /space/mlcp/txform/data \ -transform_module /example/mlcp-transform.xqy \ -transform_namespace "http://marklogic.com/example" \ -transform_param "my-value"
Use a command similar to the following if you installed the JavaScript transform module:
# Windows users, see Modifying the Example Commands for Windows $ mlcp.sh import -mode local -host mlhost -port 8000 \ -username user -password password \ -input_file_path /space/mlcp/txform/data \ -transform_module /example/mlcp-transform.sjs \ -transform_function transform \ -transform_param "my-value"
mlcp should report creating two documents. Near the end of the mlcp output, you should see lines similar to the following:
... INFO contentpump.LocalJobRunner: OUTPUT_RECORDS: 2 ... INFO contentpump.LocalJobRunner: Total execution time: 1 sec
Use Query Console to explore the content database associated with your XDBC App Server. Confirm that mlcp created 2 documents. If your input was in the directory /space/mlcp/txform/data
, then the document URIs will be:
/space/mlcp/txform/data/txform.xml
/space/mlcp/txform/data/txform.json
If you use the XQuery transform, then exploring the contents of txform.xml
in the database should show a NEWATTR attribute was inserted by the transform, with the value from -transform_param
. The document contents should be as follows:
<parent NEWATTR="my-value"> <child/> </parent>
If you use the JavaScript transform, then exploring the contents of txform.json in the database should show a NEWPROP property was inserted by the transform, with the value from -transform_param
. The document contents should be as follows:
{ "key": "value", "NEWPROP": "my-value"}