Name

avg( ) — returns the average of all the nodes in the node-set operands

Synopsis

Defined in: XForms 1.0
Parameters: node-set operands (required)
Return type: number

The average is computed as the sum( ) divided by the count( ) of the value of each individual node, converted into a number (as with number( )).

For an XPath data model representing the following XML:

<operands>
  <operand>3.14</operand>
  <operand>42</operand>
  <operand>0</operand>
  <operand>0.86</operand>
</operands>

The following XPath expression returns 11.5:

avg(/operands/operand)

Get XForms Essentials 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.