算術フォーマッタ

Version 22.0.8473


算術フォーマッタ


Common Math Formatters

The following formatters are the most common math formatters. An example for each formatter is provided for reference.

add(value)

Adds the input attribute/value to the value parameter and returns the result.

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>

greaterthan(value[, ifgreater][, ifnotgreater])

Returns true if the input attribute/value is greater than the value parameter, and false otherwise.

If ifgreater is supplied, then that value will be returned instead of true (if the input is greater than value), and if ifnotgreater is supplied, then that value will be returned instead of false (if the input is not greater than value).

Example

<arc:set attr="totalCost" value="[xpath(Items/Order/TotalCost)]" />
<arc:if exp="[totalCost | greaterthan(1000)]">
  <arc:set attr="highValueOrder" value="true" />
</arc:if>

lessthan(value[, ifless][, ifnotless])

Returns true if the input attribute/value is less than the value parameter, and false otherwise.

If ifless is supplied, then that value will be returned instead of true (if the input is less than value), and if ifnotless is supplied, then that value will be returned instead of false (if the input is not less than value).

Example

<arc:set attr="totalCost" value="[xpath(Items/Order/TotalCost)]" />
<arc:if exp="[totalCost | lessthan(0)]">
  <arc:throw code="1" desc="ERROR: Invalid order total." />
</arc:if>

multiply(value)

Multiplies the input attribute/value with the value parameter and returns the result.

Example

<!-- find the total cost by multiplying the price and the quantity of a purchased item -->
<arc:set attr="item.price" value="[xpath(lineitem/costperunit)]" />
<arc:set attr="item.quantity" value="[xpath(lineitem/quantitypurchased)]" />
<arc:set attr="item.totalcost" value="[item.price | multiply([item.quantity])]" />

rand(upperBound)

Generates a random integer between 0 and upperBound.

This formatter does not modify the input attribute (variable), so no such input attribute is required.

Example

<!-- add a random number to the end of a filename -->
<arc:set attr="myFilename" value="myfile-[rand(100000)].xml" />

More Math Formatters

Below is the list of less-common formatters not included in the previous section.

abs()

数値属性値の絶対値を返します。

and(value)

2つの値のAND を返します。両側の値は、1/0、yes/no、true/false である必要があります。

  • value:比較するboolean 値。

ceiling()

数値属性値以上で最小の整数を返します。

currency([integer_count])

通貨としてフォーマットされた数値を返します。

  • count:小数点以下の表示桁数を指定する数値(オプション)。デフォルトは2です。

decimal([integer_count])

Returns the numeric value formatted as a decimal number; adds commas to delimit the thousands, millions, etc.

  • count:小数点以下の表示桁数を示す数値(オプション)。デフォルトは2です。

div([value])

数値属性値をパラメータの指定された値で除算した結果を返します。

  • value:数値属性値を除算する数値(オプション)。デフォルトは2です。

divide([value])

数値属性値をパラメータの指定された値で除算した結果を返します。

  • value:数値属性値を除算する数値(オプション)。デフォルトは2です。

expr(expression)

数式を評価します。

  • expression:式。

floor()

指定された数値属性値以下で最大の整数を返します。

format(“pattern”)

Formats a numerical result based on the provided pattern and the platform’s behavior.

  • pattern: The formatting pattern to use.

Examples

<rsb:set attr="tmp" value="$1,440.123" />
[tmp]
<br>
[tmp | format("#.##")]

The tmp attribute, set to $1,440.123, is passed through the format("#.##") formatter. The result in this case is 1440.12.

<rsb:set attr="rnd" value="1055.68" />
[rnd]
<br>
[rnd | format("#.#")]

The rnd attribute, set to 1055.68, is passed through the format("#.#") formatter. The result in this case is 1055.7.

isbetween(integer_lowvalue, integer_highvalue[, ifbetween][, ifnotbetween])

属性値が、1つ目のパラメータ値以上で2つ目のパラメータ値以下の場合はtrue(またはifbetween)を返し、それ以外の場合はfalse(ifnotbetween)を返します。

  • lowvalue:確認する範囲の下限。
  • highvalue:確認する範囲の上限。
  • ifbetween:属性値が1つ目のパラメータ値以上で、2つ目のパラメータ値以下の場合に返される値(オプション)。
  • ifnotbetween:属性値が1つ目のパラメータ値以下、または2つ目のパラメータ値以上の場合に返される値(オプション)。

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

属性値がパラメータ値と等しい場合はtrue(またはifequal)を返し、それ以外の場合はfalse(ifnotequal)を返します。

  • value:属性値と比較する数値。
  • ifequal:属性値がパラメータ値と等しい場合に返される値(オプション)。
  • ifnotequal:属性値がパラメータ値と等しくない場合に返される値(オプション)。

modulus(value)

数値属性値を指定されたパラメータ値で除算した係数を返します。

  • value:属性値を除算する数値。

or(value)

2つの値のOR を返します。両側の値は、1/0、yes/no、true/false である必要があります。

  • value:比較するboolean 値。

percentage([integer_count])

パーセンテージとしてフォーマットされた数値を返します。

  • count:小数点以下の表示桁数を示す数値(オプション)。

pow([value])

パラメータ値で指定された指数で累乗された数値属性値を返します。

  • value:属性値を引き上げる指数(オプション)。デフォルトは2です。

round([integer_value])

パラメータで指定された小数点以下の桁数に丸められた数値属性値を返します。

  • value:小数点以下の桁数(オプション)。デフォルトは2です。

sqrt()

数値属性値の平方根を返します。

subtract([value])

数値属性値とパラメータで指定された値の差を返します。

  • value:属性値を減算する数値(オプション)。