Comments? Feedback?

This wiki does not yet support public comments (a limitation of Google Sites), so we encourage you to post your comments either:

On Twitter by responding to @orbeon.

On our community mailing list: subscribe sending an email to ops-users-subscribe@ow2.org (content of subject/body doesn't matter), you'll get a response with the email to use to send your message to the community mailing list.

Recent site activity

XForms - Performance Settings


See also XForms - JavaScript and CSS Resources.

Read-Only XForms instances with xxforms:readonly

Orbeon Forms supports an extension attribute, xxforms:readonly, on the <xforms:instance> and <xforms:submission> elements. When set to true, this attribute signals that once loaded, the instance is read-only, with the following consequences:

  • The instance is loaded into a smaller, more efficient, read-only data structure in memory.
  • Instance values cannot be updated, no Model Item Properties (MIPs) can be assigned with <xforms:bind> to the instance, and the read-only MIP is set to true for all the nodes in the instance. But a read-only instance can be replaced entirely by an <xforms:submission replace="instance">.
  • When using client-side state handling, less data might be transmitted between server and client.

Read-only instances are particularly appropriate for loading internationalization resources, which can be large but don't change.

Example:

<xforms:instance id="resources-instance" src="/forms/resources/en" xxforms:readonly="true"/>

The xxforms:readonly attribute on <xforms:instance> determines if the instance is read-only until that instance is being replaced.

After an instance is replaced, it can be read-only or not irrelevant of the of xxforms:readonly on <xforms:instance>. When the instance is replaced, the replaced instance is read-only if and only if the <xforms:submission> that does the replacement has a attribute xxforms:readonly="true".

When this attribute is set to true on <xforms:submission> and if the targetref attribute is specifed, the replacement target must be an instance's root element.

Caching of XForms instances with xxforms:cache

Availability

This is an Orbeon Forms PE feature.

Configuration

Orbeon Forms supports a boolean extension attribute, xxforms:cache, on the <xforms:instance> and <xforms:submission> elements. This attribute can be used with instances that are read-only or read-write. When set to true:

  • The instance can be shared at the application level. It is identified by its source URL and, in the case of a submission with POST or PUT method, by the body of the request sent.
  • The instance is not stored into the XForms document's state, but in a global cache, therefore potentially saving memory. If, upon loading an XForms instance or running a submission, the instance is found in the cache, it is directly retrieved from the cache. This can save time especially if the URL can take significant time to load.
  • The instance stored in cache is read-only. If the xxforms:readonly attribute is set to true (on <xforms:instance> or <xforms:submission>), a single copy of the instance is used in memory. Otherwise, a read-write copy is made.
  • In general, the URL should refer to a constant or rarely-changing XML document, and authorization credentials such as username and password should not cause different data to be loaded.

NOTE: This attribute deprecates the xxforms:shared attribute. Using xxforms:cache="true" is equivalent to using xxforms:shared="application". Using xxforms:cache="false" is equivalent to using xxforms:shared="document".

Here is how you use the attribute on <xforms:instance>:

<xforms:instance id="resources-instance" src="/forms/resources/en"
                 xxforms:readonly="true" xxforms:cache="true"/>

When used on <xforms:submission>, the submission has to use method="get"method="post" or method="put" method and replace="instance":

<xforms:submission serialization="none" resource="/forms/resources/fr" method="get"
                   replace="instance" instance="resources-instance"
                   xxforms:readonly="true" xxforms:cache="true"/>

NOTE: Since POST and PUT are not meant to be idempotent methods, you should use xxforms:cache="true" with these methods carefully, typically for calls to services you know are idempotent. Otherwise, incorrect or stale data might be returned by the submission.

You set the size of the shared instances cache using a property in properties.xml:

<property as="xs:integer" name="oxf.xforms.cache.shared-instances.size" value="50"/>

You can force the XForms engine to remove a shared instance from the cache by dispatching the xxforms-instance-invalidate event to it. The next time an XForms document requires this instance, it will not be found in the cache and therefore reloaded. Example:

<xforms:action ev:event="DOMActivate">
    <xforms:send submission="save-submission"/>
    <xforms:dispatch name="xxforms-instance-invalidate" target="data-to-save-instance"/>
</xforms:action>

The xxforms:invalidate-instance action allows invalidating a shared instance by resource URI, for example:

<xxforms:invalidate-instance ev:event="DOMActivate" resource="/forms/resources/fr"/>

This action also supports the xinclude attribute, which if present will only invalidate the instance with the given resource if it was loaded with a matching xxforms:xinclude attribute:

<!-- Submission loading a shared instance and enabling XInclude processing -->
<xforms:submission serialization="none" resource="/forms/resources/fr" method="get"
                   replace="instance" instance="resources-instance"
                   xxforms:readonly="true" xxforms:cache="true" xxforms:xinclude="true"/>
<!-- Action invalidating only the instance which was loaded with xxforms:xinclude="true" -->
<xxforms:invalidate-instance ev:event="DOMActivate" resource="/forms/resources/fr" xinclude="true"/>

If the xinclude attribute is not specified, any shared instance matching the resource URI is invalidated.

It is also possible to remove all shared instances from the cache by using the xxforms:invalidate-instances action, for example:

<xxforms:invalidate-instances ev:event="DOMActivate"/>

The xxforms:ttl attribute can be used to set a time to live for the instance in cache. This duration is expressed in milliseconds and has to be greater than zero. When a shared instance if found in cache but has an associated time to live, if it was put in the cache more than time to live milliseconds in the past, then the instance is discarded from the cache and retrieved again by URI as if it had not been found in cache at all. The following example expires the shared instance after one hour:

<xforms:instance id="resources-instance" src="/forms/resources/en"
                 xxforms:readonly="true" xxforms:cache="true" xxforms:ttl="3600000"/>

Warning
When using xxforms:cache="true", be sure that the data contained in the instance does not contain information that could be inadvertently shared with other XForms documents. It is recommended to use it to load localized resources or similar types of data.

Controlling item sets refreshes with xxforms:refresh-items

XForms specifies that items and itemsets are re-evaluated when processing xforms-refresh. This may happen quite often, and may lead to time-consuming re-evaluations especially when there are many or large itemsets.

Orbeon Forms supports an extension attribute, xxforms:refresh-items, on the <xforms:select> and <xforms:select1> elements. When set to true (the default), items and itemsets are re-computed upon xforms-refresh event processing. When set to false, this attribute signals that once computed, the set of items for the control will not be recomputed upon xforms-refresh event processing.

If you know that itemsets do not change over time, setting xxforms:refresh-items to false disables refreshing of the items during xforms-refresh and may yield significant performance improvements. For example:

<xforms:select1 ref="state" xxforms:refresh-items="false"><xforms:label>State</xforms:label><xforms:item><xforms:label>[Select...]</xforms:label><xforms:value/></xforms:item><xforms:itemset nodeset="instance('schema-instance')/xs:simpleType[@name = 'state']//xs:enumeration"><xforms:label ref="@value"/><xforms:value ref="@value"/></xforms:itemset></xforms:select1>

xxforms:internal appearance on <xforms:group>

<xforms:group> supports the xxforms:internal appearance, which causes the group to have no representation at all on the client:

<xforms:group model="my-model" appearance="xxforms:internal"><!-- More XForms controls --></xforms:group>

In general you won't have a need for this appearance, but it is useful as an optimization, as it leads to less HTML sent to the client. You may use it when a group is used only to change the in-scope evaluation context for nested controls and when you don't need changes to relevance which apply directly to the group to be reflected in the client.

Full update mechanism

Availability

This is an Orbeon Forms PE feature.

Rationale

By default, the XForms engine handles Ajax updates on a per-control basis. The Ajax response produced by the server contains the new "state" for each control, and if a large number of controls need to be updating, the interpreting a large number of updates and doing the corresponding changes to the DOM can be quite time consuming. In those cases, it might be faster for the server to send the full HTML so the browser can update the form in "one" operation. To trigger this mode, you need to:
  • Place the xxforms:update="full" attribute on a control if you know that nested content will have very large updates, for example a large repeat with hundreds of items. In most cases, you will place it on an <xforms:group>.
  • Be in "span" mode, as the xxforms:update="full" is not supported with the "nospan" layout.

<xforms:group xxforms:update="full">
    <xforms:repeat nodeset="value">
        <div>
            <xforms:output value="."/>
        </div>
    </xforms:repeat>
</xforms:group>

Configuration

The following property controls the approximate number of incremental updates beyond which the server sends a full update to the client:

<property as="xs:integer" name="oxf.xforms.ajax.update.full.threshold" value="20"/>

Using xxforms:update="full" is not always the right thing to do (and this is why this is a hint you need to specify explicitly rather than the default behavior):
  • When you use a xxforms:update="full" on a control, the server keeps the HTML markup for the content under that control. Also, when there are updates under that control, the server need to consider whether to send them incrementally (if the number of below a certain threshold), or as a full update. This creates some overhead compared to the case where you don't have a xxforms:update="full".

  • You can use the xxforms:update="full" on most XForms elements, but it will run less efficiently when used on:
    • An <xforms:repeat>
    • And <xforms:group> that is a around an <xhtml:tr> or <xhtml:td>.

    As a rule of thumb, you will get the most performance out of xxforms:update="full" when using it on an <xforms:group> which is not around an <xforms:tr> or <xforms:td>.