Show TOC

Background documentationFunctions: Number Locate this document in the navigation structure

 

Functions with “*” are extended functions for the Electronic File Manager: Format Definition add-on.

Parameters suffixed with a question mark “?” have a default value and can be omitted.

last ()

Description: Returns a number equal to the context size of the expression evaluation context

Sample:

<?xml version = 1.0”?>

<Text>

<Persons>

<Person>A</Person>

<Person>B</Person>

<Person>C</Person>

</Persons>

</Text>

If the context is //Persons/Person, the value of last() would be 3.

position()

Description: Returns the position or index number of the node, relative to all the selected nodes in the node list. The position of the node is 1-based, so the first node returns a position of 1.

Sample:

<?xml version = 1.0”?>

<Text>

<Persons>

<Person>A</Person>

<Person>B</Person>

<Person>C</Person>

</Persons>

</Text>

If the context is Person B, the value of position would be 2.

count(node-set)

Description: Returns the number of nodes in the node-set argument

Sample:

<?xml version = 1.0”?>

<Text>

<Persons>

<Person>A</Person>

<Person>B</Person>

<Person>C</Person>

</Persons>

</Text>

Suppose the reference number of node set Persons is PersonRef. count(%PersonRef) returns 3.

number(object?)

Description: Returns the sum of all nodes in the node set. Each node is first converted to a number value before summing.

Sample:

<?xml version = 1.0”?>

<root>

<a>1</a>

<a>2</a>

<a>3</a>

</root>

Suppose the reference number of node a is a. sum(%a) returns 6.

ceiling(number)

Description: Returns the smallest integer that is not less than the argument

Sample:

ceiling(2.5) = 3

ceiling(-2.3) = -2

ceiling(4) = 4

floor(number)

Description: Returns the largest integer that is not greater than the argument

Sample:

floor(3.5) = 3

floor(-1.3) = -2

floor(4) = 4

round(number)

Description: Returns an integer closest in value to the argument

Sample:

round(2.6) = 3

round (2.4) = 2

round(2.5) = 3

round(-1.6) = -2

round(-1.5) = -1

add(number, number, number?)

Description: Returns the sum of the arguments

Sample:

add(2, 3) = 5

subtract(number, number, number?)

Description: Returns the difference between the arguments

Sample:

subtract(6, 2, 1) = 3

multiply(number, number, number?)

Description: Returns the product of the arguments

Sample:

multiply(1, 2, 3) = 6

divide(number, number, number?)

Description: Returns the quotient of the arguments

Sample:

divide(6, 3, 2) = 1

modulus(number, number, number?)

Description: Returns the integer that can be divided without a remainder into the difference between num1 and num2

Sample:

modulus(5, 2) = 1

*sum-if(node-set, boolean)

Description: Returns the sum of the node set if arg2 is true

Sample:

<?xml version = 1.0”?>

<root>

<a>1</a>

<a>3</a>

<a>2</a>

</root>

Suppose the reference number of node a is a. sum-if(%a, true) = 6

*count-if(node-set, boolean)

Description: Returns the count of the node set if arg2 is true

Sample:

<?xml version = 1.0”?>

<root>

<a>1</a>

<a>3</a>

<a>2</a>

</root>

Suppose the reference number of node a is a. count-if(%a, true) = 3

*is-number(object value)

Description: Returns true if the argument can be converted to a number

Sample: is-number('1') returns true; is-number('NaN') returns false