Skip to content

Example: Updating a Node in a Document

Mads Hansen edited this page Jul 28, 2017 · 6 revisions

When transforming a document there is no output report. It's a straightforward process of selecting documents for transformation and then performing the transformation. The updated document will then be placed in a collection. We'll need to set the name of the selector (URIS) query, the name of the transform query, number of threads to use, the collection name and database connection information. For this example the following information is given:

  • Database name: FFE
  • Database user name: ffe-user
  • Database user password: ffe-user$pwd
  • Database IP address: localhost
  • Database port: 9500
  • Modules database: FFE-Modules
  • Name of URIS module: get-uris.xqy
  • Name of PROCESS MODULE: update-node.xqy
  • Number of threads to use: 8

Configuration Using Main Method Arguments

There can be up to 16 arguments parsed by the main method in the java.com.marklogic.developer.corb.Manager class. As with all arguments, order of placement is critical. If an option is not going to be used but is ordered before one that is going to be used empty quotes must be inserted in place of the unused option. The ordering for all is as follows:

  1. XCC-CONNECTION-URI
  2. COLLECTION-NAME
  3. PROCESS-MODULE
  4. THREAD-COUNT
  5. URIS-MODULE
  6. MODULE-ROOT
  7. MODULES-DATABASE
  8. INSTALL
  9. PROCESS-TASK
  10. PRE-BATCH-MODULE
  11. PRE-BATCH-TASK
  12. POST-XQUERY-MODULE
  13. POST-BATCH-TASK
  14. EXPORT-FILE-DIR
  15. EXPORT-FILE-NAME
  16. URIS-FILE

Therefore, to run CORB for the scenario described using method arguments would be:

java –cp "marklogic-corb-2.1.0.jar: marklogic-xcc-6.0.2.jar" com.marklogic.developer.corb.Manager  \
  xcc://ffe-user:ffe-user$pwd@localhost:9500/FFE "" \
  update-node.xqy 8 get-uris.xqy \
  "" FFE-Modules

Note that the '' is the line break designator for a bash command, the empty quotes ("") are necessary because we are not specifying a module root or a collection name for the query.

Configuration Using VM arguments

To use virtual machine property designators, '-D', for the same scenario you would use:

java –cp "marklogic-corb-2.1.0.jar: marklogic-xcc-6.0.2.jar" \
  -DXCC-CONNECTION-URI= xcc://ffe-user:ffe-user$pwd@localhost:9500/FFE \
  -DURIS-MODULE= get-uris.xqy –DPROCESS-MODULE= update-node.xqy \
  –DTHREAD-COUNT=8 \
  -DMODULES-DATABASE=FFE-Modules com.marklogic.developer.corb.Manager

Configuration Using Properties File

Here, all the properties will be put into a file called corb.properties which must be available on the classpath. For the same scenario as above, the properties file would contain:

XCC-CONNECTION-URI= xcc://ffe-user:ffe-user$pwd@localhost:9500/FFE
URIS-MODULE= get-uris.xqy 
PROCESS-MODULE= update-node.xqy 
THREAD-COUNT=8 
MODULES-DATABASE=FFE-Modules

The command line using the property file would be:

java –cp "marklogic-corb-2.1.0.jar: marklogic-xcc-6.0.2.jar" –DOPTIONS-FILE=corb.properties \
  com.marklogic.developer.corb.Manager