pc:ReplaceVariables

Previous Next

Replaces all occurrences of a given text or pattern by a different text. You can give multiple replacement instructions in one go.

Returns the text after the replacements have been made. USoft Delivery Manager uses this mechanism to do machine-specific replacements when data are deployed on target machines.

Syntax

<pc:ReplaceVariables

 
    txt="expr"

 

  {

    select="xpath >> xml-fragment"  |

    varlist="varlist"               }  

 

/>

The required txt is a regular text string, for example, a narrative text, or an SQL statement. This is the input text.

The replacement instructions must be expressed either in a select attribute or in a varlist attribute. One of these is required, but you cannot have both. You can pass input parameters to the replacement routine by using variable references in the select attribute value.

Example

In this example, each occurrence in the TRAVEL.txt file of ITALIA is translated to ITALIA and each occurrence of GERMANY to DEUTSCHLAND, and the result is returned.

<example xmlns:pc="Processing.Command" xmlns:assign="Processing.Command.Assign" >
    <pc:defs><Settings><Setting NAME="ITALY" VALUE="ITALIA"/><Setting NAME="GERMANY" VALUE="DEUTSCHLAND"/></Settings></pc:defs>
    <pc:ReadFile filepath="TRAVEL.txt" assign:fileContent="."/>
    <pc:assign-nodeset settings="{//pc:defs/*}"/>
    <pc:ReplaceVariables txt="{$fileContent}" select="$settings"/>
</example>

 

 

collapseselect, syntax
collapseselect, example with NAME only
collapseselect, example with NAME and PATTERN
collapsevarlist, syntax
collapsevarlist, example

 

 

See also

Passing input parameters to the replacement routine

Variables

strings:ReplaceVariables