Logical Formatters

Version 24.1.8906


Logical Formatters


allownull()

Returns NULL if the attribute does not exist or the value if it does.

contains(target[, ifcontains][, ifnotcontains])

Returns true if the input string contains the target, and false otherwise.

The ifcontains parameter can be set to an alternate value to return if the input string contains the target, and the ifnotcontains parameter can be set to an alternate value to return if the input string does not contain the target.

Example

<arc:set attr="myString" value="hello world" />
<arc:if exp="[myString | contains('hello')]">
  <arc:set attr="response" value="hello to you too!" />
  <arc:else>
    <arc:set attr="response" value="I would appreciate a greeting" />
  </arc:else>
</arc:if>

def(ifnotexists[, ifexists])

Sets the ‘default’ value of an attribute: if the attribute has not yet been set to a value, set it to the value passed in ifnotexists; if the attribute already exists, set it to the value passed in ifexists.

Example

<!-- count the number of loops in an XML document using xmlDOMSearch -->

<arc:set attr="xml.uri" value="[FilePath]" />
<arc:set attr="xml.xpath" value="/Items/test/loop" />

<arc:call op="xmlDOMSearch" in="xml">
  <!-- this code will execute for each occurrence of the 'xpath' in the XML document -->
  <arc:set attr="loopCount" value="[loopCount | def(0) | add(1)]" />
</arc:call>

empty(value)

Returns the specified value if the attribute value is empty, otherwise the original attribute value.

  • value: The value that will be used if the attribute is empty.

equals(value[, ifequal][, ifnotequal])

Returns true if the input attribute matches the value, and false otherwise.

If ifequal and/or ifnotequal are provided, the values in these parameters will be returned instead of true and false, respectively.

Example

<arc:set attr="myItem.code" value="[xpath(data/lineitems/itemcode)]" />
<arc:if exp="[myItem.code | equals('A5')]">
  <arc:set attr="myItem.name" value="spoon" />
  <arc:else>
    <arc:set attr="myItem.name" value="fork" />
  </arc:else>
</arc:if>

ifequal(value[, ifequals][, ifnotequals])

Compares the attribute value with the first parameter value and returns true (or ifequals) if they are equal and false (or ifnotequals) if they are not.

  • value: The string to compare with the attribute value.
  • ifequals: The optional value returned if the attribute value equals the value represented by the first parameter.
  • ifnotequals: The optional value returned if the attribute value does not equal the value represented by the first parameter.

ifmatches(value[, ifmatch][, ifnotmatch])

Returns true (or ifmatch) if the attribute value matches the first parameter, otherwise false (or ifnotmatch).

  • value: The value that will be compared with the attribute value.
  • ifmatch: The optional value returned if the attribute value matches the parameter value.
  • ifnotmatch: The optional value returned if the attribute value does not match the parameter value.

isalphabetic([ifalpha][, ifnotalpha])

Returns true (or ifalpha) if all characters in the attribute value are alphabetic and there is at least one character, false (or ifnotalpha) otherwise.

  • ifalpha: The optional value returned if the attribute value is alphabetic.
  • ifnotalpha: The optional value returned if the attribute value is not alphabetic.

isalphanumeric([ifalphanum][, ifnotalphanum])

Returns true (or ifalphanum) if all characters in the attribute value are alphanumeric and there is at least one character, false (or ifnotalphanum) otherwise.

  • ifalphanum: The optional value returned if the attribute value contains only alphabetic or numeric characters.
  • ifnotalphanum: The optional value returned if the attribute value contains nonalphabetic or nonnumeric characters.

islower([iflower][, ifnotlower])

Returns true (or iflower) if all letters in the attribute value are lowercase and there is at least one character that is a letter, false (or ifnotlower) otherwise.

  • iflower: The optional value returned if the attribute value is lowercase.
  • ifnotlower: The optional value returned if the attribute value is not lowercase.

isnumeric([ifnum][, ifnotnum])

Returns true (or ifnum) if all characters in the attribute value are digits and there is at least one character, false (or ifnotnum) otherwise.

  • ifnum: The optional value returned if the attribute value is numeric.
  • ifnotnum: The optional value returned if the attribute value is not numeric.

isspace([ifspace][, ifnotspace])

Return true (or ifspace) if there are only white-space characters in the attribute value and there is at least one character, false (or ifnotspace) otherwise.

  • ifspace: The optional value returned if the attribute value is a space.
  • ifnotspace: The optional value returned if the attribute value is not a space.

isupper([ifupper][, ifnotupper])

Returns true (or ifupper) if all letters in the attribute value are uppercase and there is at least one character that is a letter, false (or ifnotupper) otherwise.

  • ifupper: The optional value returned if the attribute value is uppercase.
  • ifnotupper: The optional value returned if the attribute value is not uppercase.

notequals(value[, notequals][, equals])

Compares the attribute value with the first parameter value. Returns true (or notequals) if they are not equal and false (or equals) if they are.

  • value: The string to compare with the attribute value.
  • notequals: The optional value returned if the attribute value does not equal the value represented by the first parameter.
  • equals: The optional value returned if the attribute value equals the value represented by the first parameter.

startswith(target[, iftrue][, iffalse])

Returns true if the input string starts with the value specified as the target, and false otherwise.

If iftrue is provided, this value is returned instead of true when the target is found, and if iffalse is provided, this value is returned instead of false when the target is not found.

Example

<arc:set attr="myString" value="Sir, your carriage is ready." />
<arc:if exp="[myString | startswith('Sir')"]>
  <arc:set attr="response" value="Thank you." />
  <arc:else>
    <arc:set attr="response" value="Use your manners." />
  </arc:else>
</arc:if>