This section defines the various number functions provided by the XForms core function library. These functions were added to the XForms core because they were missing in the XPath core but deemed necessary for typical form-based applications. Some of these functions are being adopted by the XPath working group for inclusion in XPath 2.0. 6.3.1 Computing Minimum, Maximum, and AverageThe XPath core function library defines a number of functions like sum that reduce a node-set by applying a given mathematical operation. XForms extends these with the following functions:
In Figure 6.2, we illustrate the use of these functions with a fragment from a census report. Figure 6.2 Functions min , max , and avg used in a census report.< html xmlns ="http://www.w3.org/1999/xhtml" xmlns:xf ="http://www.w3.org/2002/xforms"> < head >< title >Census Report</ title > < xf:model id ="data"> < xf:instance xmlns =""> < census > < state >< population /></ state > </ census ></ xf:instance > </ xf:model ></ head > < body > < xf:group xmlns ="http://www.w3.org/2002/xforms"> < output value ="min(/census/state/population)"> < label >Smallest population</ label ></ output > < output value ="max(/census/state/population)"> < label >Largest population</ label ></ output > < output value ="avg(/census/state/population)"> < label >Avg state population</ label ></ output > </ xf:group ></ body > </ html > 6.3.2 Function index for Addressing |