11.2 String Deciders |
Whenever the XML allows a string decider (instead of a concrete string), these are the valid options:
calculate
> element.calculate
> element.component
id
="nameOfTextbox"
/>) inside the parent element.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.
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>
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:
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>
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:
if
> - REQUIRED - The <if
> element is a Boolean decider that is evaluated first. It has one child element, <then
>. The <then
> element is the value of the evaluated condition if the if
decider evaluates to true.else-if
> - OPTIONAL - The <else-if
> element is a Boolean decider. If specified, it must contain a <then
> child element that is the value of the conditional if previous conditions evaluated to false. There may be zero or more <else-if
> elements.else
> - RECOMMENDED - The <else
> element does not contain a Boolean decider, but instead is the value of the conditional if the other <if
> and <else-if
> statements evaluated to false. Although optional, it is always recommended to include the <else
> element to verify that the decider always returns a value.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.
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:
regex
> - The regular expression to match.replacement
> - The string that replaces the matched expression.value
> - The original string that is evaluated. The regular expression checks this string.<calculate operation="string-replace"> <regex>\.</regex> <replacement>_</replacement> <value>Name.Of.File</value> </calculate>