Even though AVTs and <xforms:output> elements may be placed before any XForms
model, they are still considered part of the XForms "view" of the XForms document and refer to data placed in
models.
XForms Reference: Extensions
- 1. Introduction
- 2. Placement of Controls and Models
- 3. XForms 1.1 Support
- 3.1. Media Type for xforms:output
- 3.1.1. Image Types
- 3.1.2. HTML Type
- 3.2. origin Attribute on xforms:insert Action
- 3.3. context Attribute on xforms:insert Action
- 3.4. validate and relevant Attributes on <xforms:submission>
- 3.5. serialization Attribute on <xforms:submission>
- 3.6. Preliminary support for asynchronous handling of <xforms:submission>
- 3.7. Conditional Execution and Iteration of XForms Actions
- 3.8. XForms 1.1 Functions
- 3.1. Media Type for xforms:output
- 4. Extensions
- 4.1. Read-Only Mode
- 4.2. Formatting
- 4.2.1. Rationale
- 4.2.2. xforms:input
- 4.2.3. xforms:output
- 4.2.4. Default Formatting
- 4.3. Iteration of XForms Actions over Sequences
- 4.4. Generalized context attribute
- 4.5. Enhanced event() Function Support
- 4.6. Enhanced <xforms:dispatch> Support
- 4.7. Enhanced Support for xforms-select and xforms-deselect
- 4.8. Targetting effective controls within repeat iterations
- 4.9. Validation Extensions
- 4.9.1. Extension Events
- 4.9.2. Extension Types
- 4.9.3. Controlling the XML Schema Validation Mode
- 4.10. JavaScript Integration
- 4.10.1. Rationale
- 4.10.2. Getting and Setting Controls Value
- 4.10.3. Dispatching Events
- 4.11. Attribute Value Templates
- 4.11.1. AVTs on XForms Elements
- 4.11.2. AVTs on XHTML Elements
- 4.12. Variables
- 4.13. Dialogs
- 4.13.1. The xxforms:dialog Control
- 4.13.2. The xxforms:show and xxforms:hide Actions
- 4.13.3. The xxforms-dialog-open Event
- 4.13.4. The xxforms-dialog-close Event
- 4.14. Submission Extensions
- 4.14.1. HTTP Authentication
- 4.14.2. HTTP Headers Forwarding
- 4.14.3. Loading Indicator
- 4.14.4. Target
- 4.14.5. xxforms:instance Attribute
- 4.14.6. xxforms:xinclude Attribute
- 4.14.7. Submitting Binary Content
- 4.15. Other Extensions
- 4.15.1. <xxforms:script> Action
- 4.15.2. Read-Only XForms Instances with xxforms:readonly
- 4.15.3. Sharing of Read-Only XForms Instances with xxforms:shared
- 4.15.4. Controlling Item Sets Refreshes with xxforms:refresh-items
- 4.15.5. xxforms:internal Appearance on <xforms:group>
- 4.15.6. Trees with the xxforms:tree Appearance
- 4.15.7. Menus with the xxforms:menu Appearance
- 4.15.8. Autocomplete box xxforms:tree Appearance
- 4.15.9. Multiple Event Names, Observers and Targets on Event Handlers
- 4.15.10. Modal Trigger / Submit Behavior
- 5. Configuration
- 5.1. State Handling
- 5.1.1. Rationale
- 5.1.2. Configuring State Handling
- 5.1.3. Session Heartbeat
- 5.2. JavaScript and CSS Resources
- 5.2.1. Minimal Resources
- 5.2.2. Combined Resources
- 5.2.3. Versioned Resources
- 5.2.4. Examples of Apache Configurations
- 5.3. Browser Navigation (Back and Forward) Handling
- 5.4. Encryption
- 5.5. Debugging XForms Pages
- 5.5.1. Enabling XForms Logging
- 5.5.2. The Instance Inspector
- 5.1. State Handling
1. Introduction
This part of the XForms reference documentation focuses on extensions over XForms provided by Orbeon Forms, as well as XForms engine configuration.
Please be sure to visit:
2. Placement of Controls and Models
XForms does not specify normatively where XForms controls and models must be placed within an HTML
document. The convention is to place
<xforms:model> elements within <xhtml:head>, and controls within
<xhtml:body>. Orbeon Forms is more flexible on this:
-
<xforms:model>can be placed within<xhtml:head>as is usual, but also under<xhtml:body>and even nested within other XForms elements. For example:<xxforms:dialog id="my-dialog" model="my-dialog-model"><xforms:label>My Dialog</xforms:label><xforms:group>...</xforms:group><xforms:model id="my-dialog-model"><!-- Model used by the dialog -->...</xforms:model></xxforms:dialog>In this particular case, this allows you to write your dialog as a module in a completely separate file and to XInclude that file within your main form.
At the moment, nested models behave exactly as if they were placed under
<xhtml:head>. It is just a syntactic convenience to be able to place them within elements such as<xxforms:dialog>. -
Attribute Value Templates (AVTs) can be placed on HTML elements outside
<xhtml:body>.<xhtml:body lang="{instance('language')}">...</xhtml:body> -
A single
<xforms:output>control may be placed within<xhtml:title>. This allows dynamically changing the HTML document title using XForms.<xhtml:title><xforms:output value="instance('resources')/title"/></xhtml:title>
3. XForms 1.1 Support
3.1. Media Type for xforms:output
In XForms 1.0, xforms:output is only used to display text. However, XForms 1.1 supports
a mediatype attribute on that element allowing display of other media types.
3.1.1. Image Types
For the <xforms:output> control to display an image, you
need to:
-
Have a
mediatypeattribute on the<xforms:output>. That attribute must refer to an image mediatype, such asimage/*orimage/jpeg. -
Use the
valueattribute on<xforms:output>or bind to the control to a node without type, with anxs:anyURItype or with anxs:base64Binarytype.
The resulting value from the instance is interpreted either as a URI pointing to an image, or as
a base64-encoded binary representation of the image. The image will display in place of the
xforms:output. It is possible to dynamically change the image pointed to. For
example:
The image URI may or may no be reachable from the client browser. Orbeon Forms hides this from the developer. For example, to upload and show an image:
In that example, the upload control stores a temporary URI pointing to a local
file: resource. While this URI is not visible from the client web browser, the
output control automatically proxies it so that the end user can see the image.
3.1.2. HTML Type
When an xforms:output control has a mediatype
attribute with value text/html, the value of the node to which
the control is bound is interpreted as HTML content. Consider the following
XForms instance:
You bind an xforms:output control to the
html-content node as follows:
This will display the result as HTML, as expected: "This is in bold!". If the
mediatype is not specified, the result would be instead: "This is in
<b>bold</b>!". In the XForms instance, the HTML content must be escaped as text. On
the other hand, the following content will not work as expected:
mediatype="text/html", an HTML
<div> element will be generated by the XForms engine to hold
the HTML data. As in HTML a <div> cannot
be embedded into a <p>, if you have a
<xforms:output mediatype="text/html"> control, you should
not put that control into a <xhtml:p>.
3.2. origin Attribute on xforms:insert Action
Orbeon Forms supports the XForms 1.1 origin attribute on the
xforms:insert action. This attribute allows specifying the source node to use as
template. This allows storing templates separately from the node-set specified by the
nodeset attribute. For example:
The template copied in this case comes from an XForms instance:
3.3. context Attribute on xforms:insert Action
Orbeon Forms supports the XForms 1.1 context attribute on the
xforms:insert action. This attribute allows specifying a context for insertion,
which along with the origin attribute allows inserting content into elements:
With original instances as follows:
The result of a first insertion is:
3.4. validate and relevant Attributes on <xforms:submission>
Orbeon Forms supports the XForms 1.1 validate and relevant attributes
on <xforms:submission>. These boolean attributes disable processing of validation
and relevance respectively for a given submission:
For more information, please visit the XForms 1.1 specification.
3.5. serialization Attribute on <xforms:submission>
Orbeon Forms supports the XForms 1.1 serialization on
<xforms:submission>. This is particularly useful to specify the value
none with a get method:
For more information, please visit the XForms 1.1 specification.
3.6. Preliminary support for asynchronous handling of <xforms:submission>
Orbeon Forms partially supports the XForms 1.1 mode="asynchronous" attribute on
<xforms:submission>. The limitations are:
-
Asynchronous submissions in an Ajax request are delayed until after everything else in the request has run (including other submissions).
-
Asynchronous submissions are "fire and forget": they only work with
replace="none"and noxforms-submit-done/xforms-submit-errorevents are dispatched. -
All asynchronous submissions started during a given Ajax request run serially.
For more information, please visit the XForms 1.1 specification.
XForms 1.1 specifies that mode="asynchronous" should be the default, but due to the
client-server nature of the Orbeon Forms XForms engine, Orbeon Forms still defaults to
mode="synchronous".
3.7. Conditional Execution and Iteration of XForms Actions
Orbeon Forms supports the XForms 1.1 if and while attributes on XForms
action elements. For more information, please visit the XForms 1.1 specification.
3.8. XForms 1.1 Functions
[TODO: List all XForms 1.1 functions implemented]
4. Extensions
4.1. Read-Only Mode
4.1.1. Making an Entire Instance Read-Only
You often want to present a form without allowing the user to enter data. An easy solution is to use
the readonly MIP in the model. By making for example the root element of an instance
read-only, all the controls bound to any node of that instance will appear read-only (because the
read-only property is inherited in an instance):
4.1.2. Static Appearance for Read-Only Mode
Sometimes, read-only controls don't appear very nicely in web browsers. For example, a combo box will appear grayed out. It maybe be hard to read, and there is not much point showing a combo box since the user can't interact with it. Furthermore, with some browsers, like IE 6 and earlier, it is not even possible to make disabled controls appear nicer with CSS. In order to make read-only versions of forms look nicer, Orbeon Forms supports a special extention attribute that allows you to produce a "static" appearance for read-only controls. You enable this on your first XForms model:
The attribute takes one of two vales: static or dynamic (the default).
When using the value static, read-only controls do not produce disabled HTML form
controls. This has one major limitation: you can't switch a control back to being read-write once
it is displayed as read-only.
You can also set the xxforms:readonly-appearance attribute directly on individual
XForms controls.
See the Government Forms sample application's View Read-Only option for an example of this feature in action.
4.2. Formatting
4.2.1. Rationale
It is usually recommended to use native XML types within XForms instances, as this guarantees
interoperability and maintainability. For example, a date of January 10, 2005 is stored in ISO
format as: 2005-10-01. However it is often necessary to format such values on screen
in a user-readable format, like "January 10, 2005", "10 janvier 2005", or "10. Januar 2005".
Orbeon Forms provides an extension attribute, xxforms:format, for that purpose.
xxforms:format must contain an XPath 2.0 expression. In your XPath expression you can
use all the XPath 2.0 functions, including those for date manipulation (external
documentation). However since XPath 2.0 functions don't provide any facility for date and time
formatting, you can in this attribute also use the following XSLT 2.0 functions:
-
format-date()(external documentation) -
format-dateTime()(external documentation) -
format-time()(external documentation) -
format-number()(external documentation)
The XPath expression is evaluated by the XForms engine whenever the value bound to the
xforms:input control changes and needs to be updated on screen. It is evaluated in the
context of the instance node bound to the control. This means that the current value of the control
can be accessed with ".". Often the value must be converted (for example to a date) in
which case the conversion can be done with a XPath 2.0 constructor such as xs:date(.)
or with as cast such as (. cast as xs:date?).
4.2.2. xforms:input
When using xforms:input and a bound xs:date type, you can control the
formatting of the date using the xxforms:format extension attribute on the
xforms:input control. For example:
This only controls the appearance of the date as shown to the user. It does not control the format of the date captured in the XML document, or determines the format into which the user can type the date.
4.2.3. xforms:output
When using xforms:output, you can control the formatting of the date using the
xxforms:format extension attribute on the xforms:output control.
4.2.4. Default Formatting
For both xforms:input and xforms:output, if the bound node is of one of
the following types: xs:date, xs:dateTime, xs:time,
xs:decimal, xs:integer, xs:float, and xs:double,
and if no xxforms:format attribute is present on the control, formatting is based on
properties. If the properties are missing, a built-in default
formatting is used. The default properties, as well as the built-in defaults, are as follows:
They produce results as follows:
-
2004-01-07asxs:dateis displayed asWednesday January 7, 2004 -
2004-01-07T04:38:35.123asxs:dateTimeis displayed asWednesday January 7, 2004 04:38:35 UTC -
04:38:35.123asxs:timeis displayed as04:38:35 UTC -
123456.789asxs:decimalis displayed as123,456.79 -
123456.789asxs:integeris displayed as123,456 -
123456.789asxs:floatorxs:doubleis displayed as123,456.789
Note:
- With the "if" condition in the XPath expressions, a value which cannot be converted to the appropriate type is simply displayed as is.
- For values of type xs:time or xs:dateTime, if you wish the time to be displayed using the current timezone instead of UTC, replace in the value attribute UTC by [ZN].
4.3. Iteration of XForms Actions over Sequences
Orbeon Forms supports the exforms:iterate attribute, also available as
xxforms:iterate attribute, on XForms action elements. Consider the following
instances:
The following action iterates over the <title> elements of
source-instance. For each of those, a new <book> element, copied from
the template stored in template-instance, is inserted into main-instance.
Then values from the <title> and <author> elements are copied over
to the new structure. The XForms 1.1 context() function provides access to each of the
iterated nodes:
The resulting main-instance is as follows:
Note that because Orbeon Forms uses XPath 2.0, xxforms:iterate is not limited to
returning node-sets, but can return sequences of items such as strings.
For more information about eXforms extensions, please visit the eXforms site.
4.4. Generalized context attribute
XForms 1.1 introduces the context attribute on <xforms:insert> and
<xforms:delete>. Orbeon Forms supports this convenient attribute on all XForms
elements changing the XPath evaluation context, including controls, actions, binds, and
submissions.
The context attribute overrides the in-scope XPath evaluation context for an action. It
applies before the ref and context attributes, but after the
model attribute.
One convenient use is to just change the context within a group:
Note that it is also possible to use ref in this case, but doing so has the side effect
of binding the group to an instance data node, which may affect group relevance, for example.
4.5. Enhanced event() Function Support
Orbeon Forms enhances the XML Events event() function to take a qualified name as
parameter:
This allows namespacing attribute names, therefore better allowing for extension attributes.
The following standard event attributes are implemented:
[TODO: describe standard Orbeon Forms support for event() function]
On all events, the following extension attributes are supported:
-
event('xxforms:type') as xs:stringReturn the event type (also known as event name), for example
"DOMActivate". -
event('xxforms:target') as xs:stringReturn the id of the event target.
-
event('xxforms:bubbles') as xs:booleanReturn whether the event is allowed to bubble or not.
-
event('xxforms:cancelable') as xs:booleanReturn whether the event is cancelable or not.
On all UI events (DOMActivate, DOMFocusIn, DOMFocusOut,
xforms-select, xforms-deselect, xforms-enabled,
xforms-disabled, xforms-help, xforms-hint,
xforms-valid, xforms-invalid, xforms-required,
xforms-optional, xforms-readonly, xforms-readwrite,
xforms-value-change), the following extension attributes are supported:
-
event('xxforms:binding') as node()?Return the event target's single-node binding if any.
-
event('xxforms:label') as xs:string?Return the event target's label value if any.
-
event('xxforms:hint') as xs:string?Return the event target's hint value if any.
-
event('xxforms:help') as xs:string?Return the event target's help value if any.
-
event('xxforms:alert') as xs:string?Return the event target's alert value if any.
-
event('xxforms:repeat-indexes') as xs:string*Return the event target's current repeat indexes, if any, starting from the ancestor repeat.
On xforms-select, the following extension attributes are supported:
-
event('xxforms:item-value')When this event is dispatched to in response to a selection control item being selected, returns the value of the selected item.
On xforms-submit-serialize, the following extension attributes are supported:
-
event('xxforms:binding') as node()?Return the submission's single-node binding if any.
-
event('xxforms:serialization') as xs:stringReturn the submission's requested serialization, e.g.
application/xml,application/x-www-form-urlencoded, etc..
4.6. Enhanced <xforms:dispatch> Support
Orbeon Forms supports passing event context attributes with the <xxforms:context>
child element. The actions supported are actions which directly cause an event to be dispatched:
-
<xforms:dispatch> -
<xforms:send> -
<xxforms:show> -
<xxforms:hide>
Here is how you pass context attributes when executing an action:
<xxforms:context> supports the following two attributes:
name |
Mandatory | Name of the context attribute. In order to avoid confusion with standard XForms names, we recommend you use qualified names. |
|---|---|---|
select |
Mandatory | XPath 2.0 expression determining the value of the context attribute. |
Context attribute passed this way can be retrieved using the event() function:
At the moment, with, <xforms:dispatch>, only custom events support passing
context attributes this way. Built-in events, such as xforms-value-changed, or
DOMActivate, ignore nested <xxforms:context> elements.
4.7. Enhanced Support for xforms-select and xforms-deselect
[TODO: describe support for these events on xforms:upload]
4.8. Targetting effective controls within repeat iterations
The following actions all support attributes resolving to a particular control:
-
<xforms:dispatch>(targetattribute) -
<xforms:setfocus>(controlattribute) -
<xforms:toggle>(caseattribute) -
<xxforms:show>(neighborattribute)
When that control is within a repeat iteration, the actual control targetted is chosen based on the
current set of repeat indexes. However, in some cases, it is useful to be able to target the control
within a particular iteration. This is achieved with the xxforms:repeat-indexes
extension attribute on these actions. This attribute takes a space-separated list of repeat
indexes, starting with the outermost repeat. Example:
4.9. Validation Extensions
4.9.1. Extension Events
Orbeon Forms supports extensions events dispatched to an instance when it becomes valid or
invalid: xxforms-valid and xxforms-invalid. These events are
dispatched just before xforms-revalidate completes, to all instances of the model
being revalidated. For a given instance, either xxforms-valid or
xxforms-invalid is dispatched for a given revalidation.
These events can be used, for example, to toggle the appearance of icons indicating that a form is valid or invalid:
4.9.2. Extension Types
Orbeon Forms supports the built-in xxforms:xml extension type. This types checks
that the value is well-formed XML:
Note that this checks the string value of the node, which means that the node must contain escaped XML.
Orbeon Forms supports the built-in xxforms:xpath2 extension type. This types
checks that the value is well-formed XPath 2.0. Any variable used by the expression is assumed
to be in scope:
In both these cases, Orbeon Forms checks for the required MIP: if it evaluates
to false() and the value is the empty string, then the instance data node is
considered valid. This is contrary to XForms 1.1 as of August 2008.
4.9.3. Controlling the XML Schema Validation Mode
When an XML Schema is provided, Orbeon Forms supports controlling whether a particular instance is validated in "lax" mode, "strict" mode, or not validated at all.
Orbeon Forms implements a "lax" validation mode by default, where only elements that have definitions in the imported schemas are validated. Other elements are not considered for validation. This is in line with XML Schema and XSLT 2.0 lax validation modes, and with the default validation mode as specified in XForms 1.1
In addition, the author can specify the validation mode directly on each instance with the
extension xxforms:validation attribute, which takes values lax
(the default), strict (the root element has to have a definition in the schema
and must be valid), or skip (no validation at all for that instance).
Nodes validated through a schema receive datatype annotations, which means that if an element
or attribute is validated against xs:date in a schema, an XForms control bound to
that node will display a date picker.
4.10. JavaScript Integration
4.10.1. Rationale
While XForms gets you a long way towards creating a dynamic user-friendly user interface, there are some dynamic behaviors of the user interface that cannot be implemented easily or at all with XForms, or you might already have some JavaScript code that you would like to reused. A JavaScript API is provided to handle those cases, or other use cases involving JavaScript that you might have.
4.10.2. Getting and Setting Controls Value
In JavaScript, you get the current value of an XForms control var value =
ORBEON.xforms.Document.getValue("myControl") where myControl is the id of
the XForms control, for instance: <xforms:input id="myControl">.
You set the value of an XForms control with ORBEON.xforms.Document.setValue("myControl",
"42") where myControl is the id of the XForms control, and 42
the new value. Setting the value with JavaScript is equivalent to changing the value of the
control in the browser. This will trigger the recalculation of the instances, and the dispatch
of the xforms-value-changed event. More formally, the Value Change sequence of
events occurs.
As an example, consider you have the model below. It declares an instance with two elements
foo and bar, where bar is a copy of foo,
implemented with a calculate MIP.
The input control below is bound to foo, and the output control is bound to
bar. When activated, the trigger executes JavaScript with the
<xxforms:script> action. It increments the value of the input control bound to
foo. When this happens the value displayed by the output control bound to
baris incremented as well, as bar is a copy of foo.
4.10.3. Dispatching Events
You can dispatch your own events from JavaScript by calling the function
ORBEON.xforms.Document.dispatchEvent(). The parameters to this function are:
| targetId | Mandatory |
Id of the target element. The element must be an element in the XForms namespace: you
cannot dispatch events to HTML elements. In addition, the id must identify either a
relevant and non-readonly XForms control, or a model object that supports event handlers
such as <xforms:model>, <xforms:instance>, or
<xforms:submission>.
|
|---|---|---|
| eventName | Mandatory |
Name of the event. Warning
For security reasons, by default Orbeon Forms prohibits client-side JavaScript
from dispatching any external events except <xforms:model xxforms:external-events="acme-super-event acme-famous-event">...</xforms:model>
This attribute contains a space-separated list of event name. In this example,
you explicitly enable your JavaScript code to fire the two events
Since the event handlers for custom events can be called by JavaScript code that runs on the client, you need to be aware that these handlers can potentially be activated by anybody able to load the form in his browser. |
| form | Optional |
The form object that corresponds to the XForms form you want to dispatch the event to.
This argument is only needed when you have multiple "XForms forms" on the same HTML
page. Typically, this would only happens if you are running your form in a portal and
you have multiple portlets using XForms on the same page. When the parameter is not
present or null, the first form on the HTML page with the class
xforms-form is used.
|
| bubbles | Optional | Optional boolean indicating if this event bubbles, as defined in DOM2 Events. The default value depends on the definition of the custom event. |
| cancelable | Optional | Optional boolean indicating if this event bubbles, as defined in DOM2 Events. The default value depends on the definition of the custom event. |
| incremental | Optional |
When false the event is sent to the XForms server ri |