XForms Functions





Introduction

The previous chapter showed how XPath expressions can be used in calculating the values of certain form fields. When writing such expressions, it is useful to have a standard set of utility functions for performing common computations. As explained in Section 2.2, XPath expressions can use functions that are defined in the XPath specification. In addition, XPath makes it possible to define extension functions for use in languages that adopt XPath as the base expression language. XForms 1.0 defines a handful of such extension functions, and these will be described in the rest of this chapter along with motivating examples for each. We refer to this collection of functions as the XForms core function library. XForms authors can depend on the availability of all core XForms functions in addition to the predefined XPath functions.

XForms 1.0 uses XPath 1.0, which has a comparatively restrictive set of data types compared with XML Schema. XPath 1.0 defines only four basic types:

  1. boolean

  2. number

  3. string

  4. nodeset

XPath 2.0, currently under development, has support for the full set of XML Schema data types, and future versions of XForms will use the richer function libraries provided by XPath 2.0. When working with XForms 1.0, the restricted access to types in XPath 1.0 needs careful attention when working with XML Schema types such as xsd:date. Many of the extension functions provided by the XForms core function library are designed to hide some of these difficulties from the XForms author.

Functions in the XForms core can be classified according to the data types they operate on, and we will use this classification to organize the rest of this chapter into sections. In addition to the XForms core function library, XForms like XSLT 1.0[1] encourages experimentation by allowing authors and implementations to provide additional extension functions. Such extension functions, if used, must be declared via attribute functions on element model. This enables XForms processors to check for the availability of all needed functions when loading a document, rather than encountering a fatal error during user interaction.

[1] http://www.w3.org/tr/xslt


     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows