Standard functions
XPath 2.0 functions
Standard documentation
These functions are documented in XQuery 1.0 and XPath 2.0 Functions and Operators (Second Edition).
Functions
Orbeon Forms supports the XPath functions from XQuery 1.0 and XPath 2.0 Functions and Operators (Second Edition).
Example of use:
Namespaces:
These functions are available in the default function namespace.
These function are also available in the XPath functions namespace (
http://www.w3.org/2005/xpath-functions
), usually associated with thefn
prefix.
This means that it is usually not necessary to declare a namespace for these functions, nor is it necessary to use a prefix in calls to these functions.
We recommend not prefixing calls to the standard XPath functions.
Constructors
Orbeon Forms supports the XPath constructors from XQuery 1.0 and XPath 2.0 Functions and Operators (Second Edition).
Example of use:
These constructors are in the http://www.w3.org/2001/XMLSchema
namespace, usually associated with the xs
prefix. This means that using a prefix is required.
XPath 3.0 functions
Math functions
[SINCE Orbeon Forms 2020.1]
This version doesn't yet support XPath 3.0, but it supports a subset of XPath 3.0 math functions. These functions are in the http://www.w3.org/2005/xpath-functions/math
namespace, which maps to the math
prefix:
math:log()
math:sin()
math:cos()
math:tan()
math:asin()
math:acos()
math:atan()
math:atan2()
math:log()
math:exp()
For more information, see Trigonometric and exponential functions.
environment-variable()
[SINCE Orbeon Forms 2020.1]
This function returns the value of the specified environment variable. Before using this function, you'll want to set the oxf.xpath.environment-variable.enabled
property to true
. If that property isn't set to true, or the variable isn't defined, or the Java security doesn't allow access to environment variables, then the function returns an empty sequence.
XForms functions
Standard documentation
These functions are documented in XForms 2.0's XPath Expressions Module.
Namespaces
These functions are available in the default function namespace.
These function are also available in the XForms namespace (
http://www.w3.org/2002/xforms
), usually associated with thexf
prefix.
This means that it is usually not necessary to declare a namespace for these functions in the form, nor is it necessary to use a prefix in calls to the core XPath functions:
For extra clarity, you can prefix calls to XForms functions. For example:
XForms 2.0 functions
xf:bind()
[SINCE Orbeon Forms 4.5]
This function returns the sequence of nodes associated with the bind specified by the id
parameter.
xf:valid()
[SINCE Orbeon Forms 4.3]
The valid()
function returns the validity of XPath items, including instance data nodes.
Boolean functions
xf:boolean-from-string()
xf:is-card-number()
Number functions
xf:count-non-empty()
xf:index()
xf:power()
xf:random()
String functions
xf:property()
This function supports extension property names in the
http://orbeon.org/oxf/xml/xforms
namespace (usually mapped to thexxf
prefix). Any such property name will return the value of an XForms engine property. Example:NOTE: The standard XForms function returns an XPath 1.0
string
. The Orbeon Forms implementation returns the following:empty sequence (if the property is not found)
xs:string
,xs:integer
,xs:boolean
orxs:anyURI
depending on the type of the property
xf:digest()
xf:hmac()
Date and time functions
NOTE: Prefer the XPath 2.0 date and time functions when possible.
xf:local-date()
xf:local-dateTime()
xf:now()
xf:days-from-date()
xf:days-to-date()
xf:seconds-from-dateTime()
available as
xf:seconds-from-dateTime()
only
xf:seconds-to-dateTime()
xf:seconds()
xf:months()
Node-set functions
xf:instance()
xf:current()
xf:context()
Object functions
xf:event()
Unsupported and obsolete XForms 1.1 functions
The following functions from XForms 1.1 are obsolete:
xf:adjust-dateTime-to-timezone()
use the XPath 2.0 Timezone Adjustment Functions on Dates and Time Values, which offer similar functionality
xf:avg()
use the standard XPath 2.0 function instead (
avg()
)the XForms 1.1 version of this function is not implemented in Orbeon Forms
xf:choose()
use the native XPath 2.0
if (...) then ... else ...
construct instead
xf:id()
use the native XPath 2.0
id()
function instead
xf:if()
available as
xf:if()
onlyuse the native XPath 2.0
if (...) then ... else ...
construct instead
xf:min()
,xf:max()
use the standard XPath 2.0 functions instead (
min()
andmax()
)the XForms 1.1 versions of these functions are not implemented in Orbeon Forms
XSLT 2.0 functions
Namespaces
These functions are available in the default function namespace.
Example:
Functions
The following functions from XSLT 2.0 and XPath 3 are available:
format-dateTime()
(external documentation)format-date()
(external documentation)format-time()
(external documentation)format-number()
(external documentation)
NOTE: Orbeon Forms, as of version 2021.1, still uses XPath 2.0. Even so, the functions above are available.
For an example, see Converting a date/time to a named timezone.
eXforms functions
Namespaces
These functions are available in the http://www.exforms.org/exf/1-0
namespace, usually associated with the exf
prefix.
Functions
eXForms was a suggested set of extensions to XForms 1.0, grouped into different modules.
Orbeon Forms supports the exf:mip
module, which includes the following functions:
exf:relevant()
exf:readonly()
exf:required()
NOTE: XPath 2.0-compatible versions of these functions will be available as part of XForms 2.0.
Orbeon Forms also supports the following from the sorting module:
Note that the second argument is interpreted as a string, unlike with xxf:sort()
:
Last updated