XPath provides some functions to aid the calculation of numeric values:
- number()
- Converts a string to a number, use it to be precise.
- round()
- Converts value to a number, round to nearest integer
- round(1.6) is 2; round(1.4) is 1; round(1.5) is 2
- ceiling()
- Converts value to a number, round up to next highest integer
- ceiling(1.6) is 2; ceiling(2) is 2; ceiling(-1.6) is -1
- floor()
- Converts value to a number, round down to next lowest integer
- floor(1.6) is 1; floor(2) is 2; floor(-1.6) is -2
- sum()
- Converts the string value of each node in the node-set to a
number and sum these numbers
- count()
- Returns the number of nodes in the node-set