npsobj insertvalue systemexecute

Syntax

npsobj_insertvalue_systemexecute ::=

  <npsobj insertvalue = "systemexecute" name = "name" >
    content
  </npsobj>

Task

Using this instruction, a computed value can be inserted into an output file created during the export. The instruction is often used to reformat field values of the file being exported (e.g. date values), or to compute a value from several field values.

For this the Tcl procedure referenced by name is called. To the procedure two arguments are passed, the ID of the file or link concerned, and the evaluated content. The NPSOBJ instruction is then replaced with the return value of the procedure.

name is taken to be the alias of a procedure name that has been specified in the export.tclSystemExecuteCommands system configuration entry. If the alias is not present in tclSystemExecuteCommands, no Tcl command is executed. Instead, the NPSOBJ element is replaced by the string Error: Execution of '<name>' not allowed.

Please note that the procedures to be executed at export-time must also be available on the live server if the Template Engine is used.

Example

The following code calls the Tcl function whose alias is command_alias. The ID of the file beeing exported and the value of the custom field attr_name are passed to the function as arguments. The code is then replaced with the function’s return value.

<npsobj insertvalue="systemexecute" name="command_alias">
  <npsobj insertvalue="var" name="attr_name"/>
</npsobj>