Each function in Table 6.4 returns a number.
| Function | Meaning | ||
|---|---|---|---|
| ceiling(number) | Returns the value of a numeric expression, rounded upward to the greater integer. Here are examples: | ||
| Invocation | Returns | ||
| ceiling(2) | 2 | ||
| ceiling(2.01) | 3 | ||
| ceiling(-2) | 2 | ||
| ceiling(-2.01) | -2 | ||
| ceiling(-2.99) | -2 | ||
| count(node set) | Returns the number of nodes in a node set. Given our main example, the following expression resolves to 5. count(/descendant::Vehicle[Make]) | ||
| floor(number) | Returns the value of a numeric expression, rounded downward to the lesser integer. Here are examples: | ||
| Invocation | Returns | ||
| floor(2) | 2 | ||
| floor(2.99) | 2 | ||
| floor(-2) | -2 | ||
| floor(-2.01) | -3 | ||
| floor(-2.99) | -3 | ||
| last() | Returns the context size, as described earlier. In our main example, the value of last() in the following expression is 2. (/Insured/CarPolicy/Vehicle[2]/Make)[last()] | ||
| round(number) | Returns the value of a numeric expression, rounded to the nearest integer. The next examples show the effect of mid points. | ||
| Invocation | Returns | ||
| round(2.499) | 2 | ||
| round(2.5) | 3 | ||
| round(-2.5) | -2 | ||
| round(-2.501) | -3 | ||
| string-length(string) | Returns the number of characters in the argument. Given our example, the following invocation returns 5(the number of letters in Honda). string-length(/descendant::Make[1]) | ||
| sum(node set) | Returns the sum of the numeric values in each node in a node set. If the node includes non-numeric text, the returned value is NaN (not a number). Consider the following XML source
<?xml version="1.0"?> <Options> <Towing>50</Towing> <Rental>20</Rental> </Options> The following expression resolves to 70. sum(/Options/*) | ||