11.2 String Deciders

Whenever the XML allows a string decider (instead of a concrete string), these are the valid options:

11.2.1 Binary Operations

All binary operations requires <first> and <second> elements (which themselves could be deciders). The type of decider is dependent on the binary-operation attribute value.

11.2.1.1 Substring

The substring binary operation string decider requires a string decider for the <first> element and an integer for the <second> element. The result of the operation is the first n characters of the <first> element.

Here, the first three characters of the "payment-value" component are calculated.

<calculate binary-operation="substring">
 <first>
  <component id="payment-value" />
 </first>
<second>3</second>
</calculate>

11.2.2 Other Operations

Operations require the operation attribute on the <calculate> element. The attribute value determines the type of operation.

These are some other keywords to get specific strings:

11.2.2.1 Append Strings

To append multiple strings together, use the "append-in-order" decider. This requires at least two children string deciders.

<calculate operation="append-in-order">
  <value order="1">Add a new reservation with
  </value>
  <value order="2">
    <component id="procs" />
  </value>
  <value order="3"> Processor(s)</value>
</calculate>

11.2.2.2 Conditional

The conditional decider uses "if", "then", "else", and "else-if" syntax to determine the string's value. The root of the value decider is a <conditional> element that includes the following three child elements:

The following is an example of using the conditional syntax:

<conditional>
  <if comparison="equal">
   <first>
    <component id="script-chooser" />
   </first>
   <second>Upload</second>
   <then>
    <component id="upload-script" type="upload" />
   </then>
  </if>
  <else-if comparison="equal">
  <first>
    <component id="script-chooser" />
   </first>
   <second>NONE</second>
   <then>NO_VALUE</then>
  </else-if>
  <else>
   <component id="write-script" type="upload" />
  </else>
 </conditional>

In the preceding example, if the "script-chooser" component was "Upload", then the value is the value of the "upload-script" component. Else if the "script-chooser" component was "NONE", then the value would be "NO_VALUE". If neither of these conditions are true, then the value would be the value of the "write-script" component.

11.2.2.3 String Replace

The string replace decider is where the decider replaces all instances of the first string with the second string. The three required children elements are:

<calculate operation="string-replace">
 <regex>\.</regex>
 <replacement>_</replacement>
 <value>Name.Of.File</value>
</calculate>