86
XPath Number Operators/ Functions
A list of number operators that are used with XPath expressions:
Index | Operator | Description |
---|---|---|
1) | + | It is used for addition operation. |
2) | – | It is used for subtraction operation. |
3) | * | It is used for multiplication operation. |
4) | div | It is used for division operation. |
5) | mod | It is used for modulo operation |
A list of functions on numbers that are used with XPath expressions:
Index | Function | Description |
---|---|---|
1) | ceiling() | It is used to return the smallest integer larger than the value provided. |
2) | floor() | It is used to return the largest integer smaller than the value provided. |
3) | round() | It is used to return the rounded value to nearest integer. |
4) | sum() | It is used to return the sum of two numbers. |
XPath Number Operators/ Functions Example
Let’s take an example to create a table of <employee> element with its attribute id and its child <firstname>,<lastname> <nickname> and <salary>. It calculates salary of the employees and then displays the result.
Employee.xml
Employee.xsl
Output:
Next TopicXPath String Functions