Controls functions

xxf:binding()

xxf:binding(
    $control-id as xs:string
) as item()*

The xxf:binding() function returns a control's binding, that is the item or items to which the control is bound. Use this function carefully, as depending on when this function is called during XForms processing, it may refer to stale items. It is usually safe to use xxf:binding() in response to UI events.

<!-- Store the value of the element to which the first-name control is bound -->
<xf:setvalue ref="my-value" value="xxf:binding('first-name')"/>

NOTE: This function can return not only nodes, but also atomic items.

xxf:binding-context()

xxf:binding-context(
    $control-id as xs:string
) as item()?

The xxf:binding-context() function returns the context of a control's binding, that is the single in-scope context item before the control's binding is applied if present. Use this function carefully, as depending on when this function is called during XForms processing, it may refer to stale items. It is usually safe to use xxf:binding-context() in response to UI events.

<!-- Store the value of the element to which the first-name control is bound -->
<xf:var
    name="context"
    value="xxf:binding-context('my-custom-component')"/>

NOTE: Before Orbeon Forms 2016.1, this function could return more than one item when called for a component within a repeat. This was incorrect and has been fixed. See #2642arrow-up-right.

NOTE: This function is rarely used, and when used is typically used from within XBL components.

NOTE: This function can return not only nodes, but also atomic items.

xxf:case()

The xxf:case() function returns the id of the currently selected <xf:case> within the given <xf:switch>. It is recommended to use this function from XForms actions only.

xxf:cases()

The xxf:cases() function returns a sequence of ids of <xf:case> elements within the given <xf:switch>. It is recommended to use this function from XForms actions only.

xxf:client-id()

[SINCE Orbeon Forms 4.3]

Resolve the XForms object with the id specified, and return the id as used on the client.

Return the empty sequence if the resolution fails.

xxf:component-param-value()

[SINCE Orbeon Forms 2017.1]

The xxf:component-param-value() function returns the string value of the given parameter of the current XBL component's bound node.

A parameter is specified by:

  • an attribute on the XBL bound node (which can be an attribute value template (AVT))

  • or, if not found, a property of the form oxf.xforms.xbl.$PREFIX.$NAME.$PARAMETER

This function is intended for XBL component implementors.

If the user of the component writes:

The implementor of the component can use the parameter with:

xxf:context()

The xxf:context() function allows you to obtain the single-node binding for an enclosing xf:group, xf:repeat, or xf:switch. It takes one mandatory string parameter containing the id of an enclosing grouping XForms control. For xf:repeat, the context returned is the context of the current iteration.

See also the XForms 1.1 context() function, which returns the current evaluation context:

xxf:index()

The xxf:index() function behaves like the standard XForms index() function, except that its argument is optional. When the argument is omitted, the function returns the index of the closest enclosing <xf:repeat> element. This function must always be used within <xf:repeat> otherwise an error is raised.

xxf:is-control-readonly()

[SINCE Orbeon Forms 2017.1]

The xxf:is-control-readonly() function returns true() if and only if the controlled specified by $control-id exists, is relevant, and is readonly.

xxf:is-control-relevant()

[SINCE Orbeon Forms 2016.3]

The xxf:is-control-relevant() function returns true() if and only if the controlled specified by $control-id exists and is relevant.

xxf:is-control-required()

[SINCE Orbeon Forms 2017.1]

The xxf:is-control-required() function returns true() if and only if the controlled specified by $control-id exists, is relevant, and is required.

xxf:is-control-valid()

[SINCE Orbeon Forms 2017.1]

The xxf:is-control-valid() function returns true() if and only if the controlled specified by $control-id exists, is relevant, and is valid.

xxf:itemset()

The xxf:itemset() function returns the current value of a given control's itemset.

  • The first parameter is the id of a selection control (<xf:select> or <xf:select1>).

  • The second parameter is the format to return:

    • xml: an XML document, useful when the result is handled directly in XForms; specifically, the document is returned

    • json: a JSON tree, useful when the result is handled from JavaScript

  • The third, optional parameter determines whether information about selected items is returned

The resulting tree represents the itemset hierarchy as seen by the control, with the following information:

  • relevant items

  • hierarchy of the itemset

  • item label

  • item value

  • item help and hint if present [SINCE Orbeon Forms 4.5]

  • item attributes (JSON only)

    • class attribute if present

    • style attribute if present

    • xxforms-open attribute if xxf:open is present

  • which are the currently selected items, if $selected-items is true()

NOTE: Because itemsets re-evaluate during refresh, it is recommended that this function be used only within action handlers responding to refresh events to ensure consistency.

With the following flat instance and itemset:

Example of XML result with xxf:itemset('my-select1', 'xml', true()) (formatted for readability)

In this example, you can access the label of the selected item with xxf:itemset('my-select1', 'xml', true())/itemset/choices/item[@selected = 'true']/value. The following is an example of JSON result with xxf:itemset('my-select1', 'json', true()) (formatted for readability):

With the following hierarchical instance and itemset:

Example of XML result with xxf:itemset('my-select1', 'xml', true())` (formatted for readability):

Example of JSON result with xxf:itemset('my-select1', 'json', true()) (formatted for readability):

Example of JSON result with attributes:

xxf:label, xxf:help, xxf:hint, xxf:alert

These functions return a control's current label, help, hint, or alert, given a control id.

If the control is not relevant, or does not have an associated label, help, hint, or alert, the empty sequence is returned.

xxf:pending-uploads()

The xxf:pending-uploads() function returns the number of known pending uploads in the page.

If there is no pending upload, the function returns 0.

A pending upload is an upload started but not completed yet.

NOTE: The XForms engine is informed of uploads start and completion in an asynchronous way. This function only indicates the best knowledge the server has of the status of uploads at any given time.

See also: [Upload control][?]

xxf:repeat-current()

NOTE: You can often use xxf:context() or the XForms 1.1 context() function instead.

The xxf:repeat-current() function allows you to obtain a reference to an enclosing xf:repeat's current iteration node. It takes one optional string parameter. If present, the id of the enclosing xf:repeat is searched. If absent, the function looks for the closest enclosing xf:repeat.

The xxf:repeat-current() function must be called from within an xf:repeat element.

xxf:repeat-items()

[SINCE Orbeon Forms 4.5]

NOTE: This function is also available in previous versions of Orbeon Forms as xxf:repeat-nodeset().

The xxf:repeat-nodeset() function returns the node-set of an enclosing xf:repeat. It takes a string parameter containing the id of an enclosing repeat XForms control. When the argument is omitted, the function returns the index of the closest enclosing <xf:repeat> element. This function must always be used within <xf:repeat> otherwise an error is raised.

xxf:repeat-position()

The xxf:repeat-position() function returns an enclosing xf:repeat's current iteration position. It takes one optional string parameter. If present, the id of the enclosing xf:repeat is searched. If absent, the function looks for the closest enclosing xf:repeat.

The xxf:repeat-current() function must be called from within an xf:repeat element.

xxf:value()

The xxf:value() function returns a control's value, it is has any. If the control is non-relevant or cannot hold a value (like xf:group or xf:repeat), the function returns the empty sequence.

NOTE: You must be careful when using this function as a control's value might be out of date. Keep in mind that control values are updated during refresh.

xxf:visited

Whether the given control has been visited, either by losing focus or via the <xxf:setvisited> action.

If the control is not found or not relevant, the function returns the empty sequence.

Last updated