Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 2 min read

Support

Motivation

One problem that keeps popping up when creating forms with XForms is the lack of sorting. This is an example for how it is possible to sort an instance using a XSLT stylesheet in Firefox.

Firefox XForms Example

The following model contains two instances. The first instance is the one we will sort and the second instance contains the XSLT stylesheet we will use to perform the sort.

id="default-instance">
xmlns="">

B-item
2001-05-03

A-item
2005-05-03

Z-item
2003-05-03

D-item
2002-05-03

id="stylesheet">

xmlns=""
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
match="/">

select="data/item">
type="string" select="name"/>

match="|@|text()">

select="|text()|@"/>

To perform the sort we will use the following JavaScript which will load the second instance into the Firefox stylesheet engine, then take the first instance make the transformation which will produce the sorted instance. Then the transformed instance is inserted into the model and a rebuild, recalculate, revalidate and refresh is performed.

function sort_instance(id) {
// We get the instance element
var instanceElement = document.getElementById(id);
if (instanceElement!=null) {

// XForms exposes the retrival of the instance document from the model element which should
// be the parent for the instance element.
var instance = instanceElement.parentNode.getInstanceDocument(id);

if (instance!=null) {
// Now creating the stylesheet, for this example the stylesheet document is also an instance
// but it can be loaded from many difference sources
var xslDom = instanceElement.parentNode.getInstanceDocument('stylesheet');

// create an XSLTProcessor and attach the stylesheet
var processor = new XSLTProcessor()
processor.importStylesheet(xslDom);

// now we do the sorting transformation
var resultDom = processor.transformToDocument(instance, instance);

// we then move the result info the instance dom
instance.removeChild(instance.documentElement);
instance.appendChild(resultDom.documentElement);

// and performs the updates for XForms
instanceElement.parentNode.rebuild();
instanceElement.parentNode.recalculate();
instanceElement.parentNode.revalidate();
instanceElement.parentNode.refresh();
}
}
}

Discussion

The idea of having the stylesheet in an instance makes it possible to change the behavior of the sorting by binding controls to it and change stuff like XPath expressions and other XSLT syntax.

References

This example is based upon the sample on [[1]http://landwehr.dk/blog/]

Where this page came from

This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

Get each new page of

XForms

Following means one email when a page is added, nothing when a page changes.

Following means one email when a page is added, nothing when a page changes.

Comments

Spinner Logo

Next in XForms

CC BY-SA 4.0
Xfolite is licensed under the LGPL license. ### PicoForms [PicoForms]( has an XForms implementation that runs on cell phones supporting MIDP 2.0 and CLDC 1.x. It also supports PDAs including Palm and Pocket PCs. PicoForms is also able to provide customers (and evaluators) with an online development
CC BY-SA 4.0
To do this do the following. From the Windows start menu click Start/Run. Enter "regedit" and press enter. Use the Registry browser to navigate to the HKEY_CLASSES_ROOT folder and then find the MIME/Daatabase/Content Type folder.
CC BY-SA 4.0
The [Apache web server]( is the most popular web server on the Internet. It provides high-performance web pages serving and is very secure. By default, the out-of-the box Apache server does not allow users to write files to a web server. This is done for security reasons.
CC BY-SA 4.0
Many of these problems could be avoided by automatically reverting to the prior version of a configuration file. ## Background With the XForms standard we are given the element and a small list of HTTP operators (GET, PUT, POST) to use and an action that can be any URL. If we want to allow users to
CC BY-SA 4.0
[eXist]( is a native XML database that has a full REST interface. This allows you to use eXist to save form data without writing any middleware glue. ## eXist REST interface eXist provides a full REST interface that is easy to call from an XForm. ## eXist WebDAV interface eXist also provides a full
CC BY-SA 4.0
Generated forms have the advantage over hand-crafted forms in that they can can be generated with the same set of transforms. If you change your form standards all the forms can be quickly be regenerated. Many of these advantage can be gained by pushing the formatting and layout functionality of a f