Extensions
Namespaces
All the generic extensions are in the namespace http://orbeon.org/oxf/xml/xbl
, and the usual mapping of this namespace is xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
.
Configuration
[SINCE Orbeon Forms 2018.2]
Element filtering can be configured by providing a custom object or class.
The following property allows adding a custom extension XPath function library:
When this property is present, the XForms engine attempts to load an extension XBL support implementation. It does this in two ways:
First, it tries to access a Scala object extending
org.orbeon.oxf.xforms.xbl.XBLSupport
.If that fails, it tries to access a Java class and calls a static
instance()
method on it to obtain anorg.orbeon.oxf.xforms.xbl.XBLSupport
.
Scala example:
Java example:
You can also turn specify this property specifically for a given form by adding an xxf:xbl-support
attribute on the first model:
xxbl:container attribute
The xxbl:container
attribute on xbl:binding
allows specifying the name of the HTML element that the XBL binding uses to encapsulate content. By default, this is xh:div
. Here is how to change it to xh:span
:
xxbl:attr attribute
The standard xbl:attr
attribute does not support accessing attributes other than those positioned exactly on the bound element. This is a serious limitation. The Orbeon Forms implementation adds an extension attribute, xxbl:attr
, which takes an XPath expression:
xbl:template/xxbl:transform attribute
When more flexibility is needed than XBL can provide, the xxbl:transform
attribute is your friend.
Orbeon Forms runs the processor specified by this attribute connecting its config
input to the content of the xbl:template
and its data
input to the bound element and replaces the content of the xbl:template
by the data
output of the processor. The most frequent expected use is to run XSLT transformations. For instance, to create a widget that alternates styles in table rows within an xf:repeat
:
This component can be invoked through:
The xbl:template/@xxbl:transform="oxf:xslt"
attribute specifies that its child element (xsl:transform
) is considered as an XSLT transformation, runs against the bound element (foo:table-alternate
), and the result of this transformation is used as the actual content of the xbl:template
.
The result of your transformation will often contain XBL attributes, and in this sample xbl:attr
attributes are used to set the style
of the rows with: <xh:tr xbl:attr="style=style1">
.
The result of the transformation has to be a (well formed) single rooted XML fragment. This might seem obvious, but that means that you might have to encapsulate the sub elements of xbl:template
in an XHTML div
or span
compared to what you would have done if you were not applying a transformation.
The transformation has full access to the bound element and can transform any of its child nodes or attributes. To keep things as encapsulated as possible and not change the behavior of bound elements that are potentially embedded, it is a good practice to define tight transformation templates that affect only the nodes that are meant to be transformed. In the example given above, one might for instance argue that <xsl:template match="foo:table-alternate/xf:repeat/xh:tr">
would be safer than <xsl:template match="xf:repeat/xh:tr">
.
You can use <xsl:message terminate="yes">
to report to the user errors that occur during the XSLT transformation. For example:
This results in an error will be output in the log, and an error message will show in the browser.
xxbl:global element
The <xxbl:global>
element allows an XBL binding to place global markup that is included in a page only once.
How this works:
The global markup is included at the end of the top-level XForms document, as if you put it there by hand.
If the XBL binding is not used, the global markup is not included.
Ids on elements in global markup must be made unique by the component author, as those ids become global as well.
The component can dispatch events to global controls if the outer scope is the top-level scope, with the xxbl:scope="outer"
attribute. For instance, if in the <xxbl:global>
you defined an <xxf:dialog id="my-dialog">
, then from within the component, you can run the following action:
NOTE: A future enhancement to this feature might restrict id and XPath scope of global markup to that of the XBL binding.
xxbl:mirror attribute
This attribute, placed on a local XForms instance, tells the XBL engine to automatically mirror changes between that instance and the XBL component's bound node.
For mirroring to work, the XBL component must either:
if it has an XPath node binding: be bound to an element node
if it doesn't have an XPath node binding: be in the XPath context of an element node (done for compatibility with Form Builder section templates)
At most one instance in a given XBL component may have xxbl:mirror="true"
.
Lifecycle:
when the XBL component becomes relevant
the XBL instance is first initialized as usual
then if the XBL binding or context points to an element, that element is extracted to become the root element of a new element, which replaces the XBL instance
when updates (value changes, inserts, deletes) take place on the XBL instance, these changes are mirrored outside
when updates (value changes, inserts, deletes) take place outside, these changes are mirrored on the XBL instance
Example:
xxbl:use-if-attr attribute
[SINCE Orbeon Forms 2018.1]
This attribute allows including a part of the resulting tree only if a particular attribute is present on the bound node.
Example:
That xf:group
element will ony be included if the bound node contains a non-blank attribute named prefix
. Otherwise, the entire subtree will be omitted.
[Orbeon Forms 2018.1 ONLY] This also checks properties such as oxf.xforms.xbl.fr.currency.prefix
and if the value of the property is found and not empty, it is as if the attribute was present on the bound node.
In the context of Form Runner, use instead the fr:keep-if-param-non-blank
attribute.
fr:keep-if-design-time
[SINCE Orbeon Forms 2018.2]
In the context of Form Runner and Form Builder, this attribute allows including a part of the resulting tree only if the form is shown at design-time or runtime.
The value of the attribute must be either:
true
: keep the element only if the form is displayed in Form Builder at design-time (this does not include thetest
mode)false
: keep the element only if the form is displayed in Form Runner at runtime (this includes thetest
mode)
fr:keep-if-param-non-blank
[SINCE Orbeon Forms 2018.2]
In the context of Form Runner, this attribute allows including a part of the resulting tree only if at least one of the following applies:
The value of the attribute is the name of the parameter to check.
The specified parameter has a corresponding attribute on the bound node which is present and non-blank.
NOTE: This does not evaluate AVTs. Only the static value of the attribute is checked.
There is a corresponding form definition metadata element with a non-blank value.
There is a corresponding configuration property with the current app name/form name which is present and non-blank.
There is a corresponding configuration property without app name/form name which is present and non-blank.
Last updated