Projects‎ > ‎

XForms - Custom XPath Functions

NOTE: This page describes an Orbeon Forms project, not a feature which is currently part of Orbeon Forms.

NOTE: See our work in progress at W3C on Custom XPath Functions.

Implementation steps

  • function should be parsed and result should be FunctionCall (or SystemFunction?)
  • Q: how to configure function's in-scope variables an functions
  • A: at first, run custom function as it it was an external (e.g. Java) function, from the POV of the caller; later, could try to build a single expression tree?
  • TODO


Function visibility works like variable visibility:
  • Functions are visible only in the scope in which they are declared.
  • Functions can use variables and other functions in scope (and cannot use variables or functions that are not in scope).

Declaration [obsolete]

  • Declaring the signature of an XForms function is similar to what is done in XSLT, using elements <xxforms:function> and <xxforms:param> which take the same attributes as their analogous XSLT functions.
  • The content of <xxforms:function> (other than the <xxforms:param>) is a sequence of actions. When the function is invoked, they run just like actions inside an <xforms:action> run when that <xforms:action> is executed.
  • The additional action <xxforms:return select="..."/> can only be used inside a function. When executing a function, the first <xxforms:return> which is hit interrupt the execution of the function and sets the return value of the function.
  • <xxforms:return/> (with no select attribute) is equivalent to <xxforms:return select="()"/>.
  • If all the actions have run without running any <xxforms:return>, then the empty sequence is returned.