The XPath Number Functions

XPath supports the following functions that operate on numbers:

  • ceiling(). Returns the smallest integer larger than the number you pass it.

  • floor(). Returns the largest integer smaller than the number you pass it.

  • round(). Rounds the number you pass it to the nearest integer.

  • sum(). Returns the sum of the numbers you pass it.

The following sections provide examples for each of these functions.

ceiling()

The ceiling function returns the smallest integer that is still larger than the number you pass it; that is, it returns the next greater integer. Here’s how you use this function:

number ceiling(number) 

For example, this expression

ceiling(3.1415926535) 

returns 4.

floor()

The floor function is the counterpart to ...

Get Inside XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.