XForms has a MVC architecture and this it what makes it so powerful when it comes to build complex applications that reach far beyond a few fields with validation. But as applications grow there naturally comes the requirement for modularization. Models are the building blocks of an XForms application.
XForms already supports multiple models on one page, each with its own, encapsulated instances and constraints. But models must be able to exchange some data in order to act as a whole in a larger architecture. Sometimes this just means to pass a single or only a few values and sometimes this means to exchange whole instances. At the same time a model should enforce some kind of encapsulation as known from object-oriented languages to ensure consistency and robustness.
Before discussing possible ways to enable model-to-model communication it should be mentioned that there is already a pattern to exchange instances between models. As two models existing in a page can perfectly use the same instance URI to load and submit data it’s already possible to ‘share’ those. But first this comes to the price of serializing the data as XML and re-parsing them when loading into the other model. Second – there will be two (detached) copies of the same instance – one in each model that need to be synchronized with each other.
Alternatives for data-exchange between models
Though XForms is not a new technology there are no established patterns for data-exchange between models. The following paragraphs are based upon our experiences with this topic. Though the need has existed before the upcoming of subforms has made the need for some kind of data-exchange more urgent as for maximum re-use of subforms (which can be full-fledged standalone forms in other contexts) you’ll likely want your models to be as independent and loosely coupled as possible.
The following paragraphs present some approaches we found during our project work over time. It should be noted that these techniques are custom betterFORM extensions to the standard but equivalents might be found in other XForms implementations.
If complete instances or larger parts of them need to be shared between models a cross-model submission is the right answer. An example might an address model that shall be re-used within a larger context that also needs the address instance data structure for incorporation into one of its instances.
<xf:submission ref="instance()" resource="context:aKey" method="put" replace="none" ...
A bit of background will help to understand what the ContextSubmissionHandler is doing. In betterFORM each instance of a XForms processor maintains a hashmap called ‘context’ with params. E.g. this map holds URL params and http headers that were used to call the XForms page and serves as a way to pass in some values for use within the form. The above submission stores the default instance into this map under the key ‘aKey’. To fetch the instance from that map the following submission can be used:
<xf:submission ref="instance('another')" resource="context:aKey" method="get" replace="instance" ...
Here the ‘get’ method is used to read the previously stored instance from the map and replace instance ‘another’ with it. For safety the submissionhandler is consuming which means that the instance will be deleted automatically from the ‘context’ hashmap once it has been read.
This kind of submission is especially useful in conjunction with subforms – if you are using multiple subforms e.g. in a wizard and you want to pass instance data from one subform to another the context hashmap is the right way to do it. Form A might already have been destroyed when loading form B but the instance data can survive within the context hashmap and be used in the next step of the wizard.
Another advantage of cross-model submissions is that one model can re-use the validation constraints and logic of another without breaking the encapsulation between the models as data exit and enter a model through its interface – the submission module. As the data are exchanged directly between models within a single instance of an XForms processor its reasonably safe to rely on validations done by a foreign model without duplicating binding constraints in both models.
The instanceOfModel() function
If there are only a few values to be passed the instanceOfModel(modelId, instanceId) function is a way to do this. It takes two params – the id of a model and the id of an instance within that model.
<xf:setvalue ref="instanceOfModel('modelA', 'default')/baz" value="instanceOfModel('modelB','default')/foo/bar"/>
In this case the value of the XPath ‘foo/bar’ in the ‘default’ instance of ‘modelB’ will be set to the node ‘baz’ in the instance ‘default’ of ‘modelA’. Easy enough but this function also is somewhat dangerous as users might expect this function to work in any context. E.g. they might expect that instanceOfModel can also be used on bind elements. But this would create inter-model dependencies which is not a healthy thing to do. The XForms dependency engine was designed to efficiently handle dependencies within one model but not to create dependencies between models. Ignoring this could cause serious consequences for the consistency of data.
For this reason this function should be used with caution. As long as its used in conjunction with the setvalue action everything should be fine but you shouldn’t use it within a model. Therefore if in doubt the method proposed in the next section should be preferred.
Dispatching custom events
Dispatching a custom event with contextinfo is a less intrusive way of passing values between models than the instanceOfModel() function (and avoids its dangers). It uses the ability of XML Events to carry context information along with the actual event. A small addition to the standard XForms dispatch action allows you to specify custom parameters for a event and pass a set of values to a target in another model. As always an example illustrates this best.
Somewhere within the scope of model ‘A’ a dispatch action is fired. It passes two params as contextinfo to the event. The first one is a static string while the second (someXPath) pulls a value from an instance in model ‘A’.
<xf:group model="A"> --- <xf:dispatch name="customEvent" targetid="foo"> <xf:contextinfo name="param1" value="'hello'"/> <xf:contextinfo name="param2" value="someXPath"/> </xf:dispatch> ... </xf:group>
Somewhere in the scope of Model ‘B’ a handler for ‘customEvent’ is defined and can access the passed params with the standard XForms event() function. – That easy.
<group model="B" id="foo"> <xf:action ev:event="customEvent"> <xf:setvalue ref="staticResult" value="event('param1')"/> <xf:setvalue ref="xpathResult" value="event('param2')"/> </xf:action> ... </xf:group>
Though this method uses a bit more markup than the instanceOfModel approach it avoids its dangers. As it passes data by value and not by reference it honors the encapsulation of models.
This article was intended to show some alternatives for the model-to-model communication in XForms. However it is assumed that this is not the end of the discussion and other ways will be invented and hopefully be standardized in future version of XForms.
As always comments and suggestions are more than welcome.
Release Notes for betterFORM limeGreen 4.1
The targets of the installer have been renamed to represent the recent name changes on the betterForm website: betterFORM XRX has become betterFORM XML Suite and the “pure” betterFORM standalone/WAR can now be found as XForms Toolkit
– fixed Syntax Highlighting for Host and Instance Documents
– fixed Error Highlighting
Release Notes for betterFORM limeGreen 4.0
In previous versions of betterFORM event logging was available on the Firebug console (or its respective counterparts in Chrome and Safari). However this worked only for the uncompressed version of betterFORM as it relied on the console.debug feature of those tools.
In betterFORM limeGreen 4.0 there is a new event log that helps tracking the events exchanged between browser and XForms processor on the server regardless of the mode of operation. It is enabled by configuring the debug option in betterform-config.xml like this:
<property name="betterform.debug-allowed" value="true" description="if true enables debug bar and event log viewer"/>
When active there will be a small icon in the upper right of the browser window. Clicking on that will reveal the event log.
In the event log each event that is received from the server will be listed with all of its context information. In some cases where an targetElement or targetId is given you can click on a link and the respective element in the browser will be highlighted in blue.
The icon in the upper right will allow to expand or collapse the event log while the trash bin icon allows to remove all entries from the log.
One of the most common errors when authoring forms is to produce a xforms-binding-exception. In complex forms these can be hard to locate. The new error highlighting feature improves this by giving you the exact line in your markup where your binding exception occurs.
In addition to the markup the requested URL and the exact XPath for the problematic element is shown.
Syntax Highlighting for Host and Instance Documents
The debug bar has been enhanced to now show the host and instance documents syntax highlighted too. Here’s an example:
Configurable Position for Ephemeral Messages
betterFORM uses a Dojox toaster control for displaying ephemeral message. These were always shown at the bottom of the screen. The position for these messages is now configurable by adding an attribute to the root node of the document:
The toaster position now can be any of the four corners of the browser window. Valid values for the attribute ‘bf:toaster-position’ are documented in the Dojo docs.
Automated Web Tests
Not strictly a new feature but we have started to automate cross-browser testing by using the new Selenium webdriver. We have already implemented a lot of tests which are now run twice a day to reveal potential regression bugs. The test assertions will be expressed in an XML format to ease the implementation of tests. From these definitions the Java code for Selenium will be generated. The tests may then be run against different browsers. We will continue to add tests and probably make the testing infrastructure available for developers that like to do their own tests.
Moved to Less for CSS Styling
LESS has a growing popularity for doing complex CSS layouts. Check out their website for an overview of the features. We decided to move all relevant CSS stylesheets to LESS as it is much more expressive than CSS and e.g. allows variables to avoid redundancies. LESS files get compiled into standard CSS so there are new dependencies at runtime nor restrictions on the use of ‘normal’ CSS files.
XForms Editor Preview
Starting with RC 2 there will be a new XForms editor in betterFORM. It will be (not in the first place) wysiwyg page editor but a pure XForms 1.1 editor which allows to edit all XForms markup contained in some (X)HTML document. It focusses on the abstract view of XForms authoring and assists to keep your markup clean and consistent. Large parts of the editor are generated directly from the XForms 1.1 schema thus supporting the full set of XForms elements and attributes plus the XML Events schema.
The first version will give access to the complete XForms language vocabulary unfiltered and will mainly target more experienced XForms authors. Starting from there ‘profiles’ will allow to filter and change the representation of the attribute editors and add authoring convenience functions.
After ‘expert mode’ (above) a ‘basic mode’ is planned as an alternative view for non-XForms users. This will works with implicit instances (instance nodes created on the fly) and smart defaults for quick editing without all the rarely used features.
What’s already working:
- parsing of any XHTML/XForms document and opening it in the editor. Only XForms markup will be shown.
- expandable/collapsible (tree-like) view of the XForms markup
- schema-aware sidebar that shows only possible children and siblings for a given element
- schema-aware dnd – still a bit quirky but allows to move elements in the tree
- schema-aware moving of elements by keyboard shortcut (this works really nice)
- ‘attribute panes’ with all possible attributes of a given XForms element which update the markup tree
- inserting and deleting of all XForms elements
- serializing changes
- applying changes to original input document
- preview, save + save as
We hope to create a tool for XForms authors to create fully valid XForms documents and appreciate all comments and suggestions. Contributors welcome.
To simplify the setup of projects using betterFORM XRX there’s a new helper build tool called ‘ProjectAssistant’. It helps to keep your project sources separate from the betterFORM sources while still giving access to the full functionality of the complete source tree. It also allows to easily switch to a newer version of betterFORM as soon as it becomes available.
There is a new Windows installer packaged as an .exe file to make installation for Windows users even easier.
A new resource handler allows to turn caching on and off.
betterFORM XRX extension for eXist
We are very happy to announce that we now have a tight cooperation with the eXist project and directly commit the XRX extension to the eXist trunk. However we will continue to offer our own eXist/betterFORM bundle as a ready-made installer packed with the latest stable version of eXist.
One hotspot of our activities was to refine the eXist integration and to fix the issues that existed in the former release. There were some inconsistencies and shortcomings of that release and we think we have finally sorted those out. Configuration and installation should now be smooth.
We also concentrated on making the betterFORM extension a good starting point for building XRX applications that are stored completely in the database. There also will be a browsing tool that lets you browse, execute and view the sources of all of your app files. Additionally you can upload files to the database and create new collections as needed.
Dashboard supports the XML application developer and XForms author in working with their resources. It lets you browse the hierarchical structure of your applications, create new collections, upload files and view the source-code. It will also allow to start the XForms editor with an additional button.
Dojo 1.6 is now integrated. All Dojo themes (tundra, soria, nihil and claro) can now be used in the forms.
Finer grained Dojo builds
Attribute Value Tempate (AVT) support
AVTs are now fully supported on foreign elements (typically HTML). That means you can use XPath expression in any HTML attribute for instance will evaluate the XPath according to the XForms in-scope context rules allowing you to manipulate the rendering of HTML from XForms.
New Submission modes
There are two new submission modes:
- a submission @replace=”embedHTML” now allows to embed HTML markup in your current document. You typically might want to use that to call some URL that produces HTML markup by templating (e.g. long output tables to display data). HTML can also be embedded by using a xf:load action but a submission gives you finer-grained control of your request (sending data if needed, validated or not, setting headers, error-handling etc.)
- a submission @replace=”new” allows to open the result of a submission in a new window. Please note that this functionality has been accepted by the XForms WG as a new feature though with a different syntax. We’ll adapt to that syntax in a later release. Typical use case is the display of printable views.
The Java classes implementing the XPath functions for XForms have substantially been refactored for easier extensibility. This is an important preparation for allowing users again to configure a new Java function library.
dispatch action supports custom contextinfo
The dispatch action now can take custom contextinfo. This is useful in context with subforms when single values shall be exchanged between models. An example illustrates that best. Assuming the action below is in scope of model A it may send either a static value or a pointer to an instance node value to model B with:
<xf:dispatch name="customEvent" targetid="foo"> <xf:contextinfo name="param1" value="'hello'"/> <xf:contextinfo name="param2" value="value"/> </xf:dispatch> <group model="B" id="foo"> <xf:action ev:event="customEvent"> <xf:setvalue ref="staticResult" value="event('param1')"/> <xf:setvalue ref="xpathResult" value="event('param2')"/> </xf:action> ...
There is a new connector with the scheme ‘context:’ that allows to store an instance into a hashmap of the XForms processor. This is a handy feature when composing wizard-style forms that are made of subforms and need to pass instance data back and forth. As the same XForms processor instance will be used over the live-time of the embedding document this can act as a global data-container for subforms.
SSL handling has been refined allowing a pluggable SocketFactory to be used. Details of the keystore can be configured in betterform-config and a howto has been added to the docs.
A control now may have multiple labels for different languages. This gives an easy alternative for quickly internationalizing forms. It’s planned to extend that approach for alerts.
The amount of events propagated to the client have been reduced dramatically. From now on only events that really have been used in a form will be propagated over the net.
There already was a feature allowing to view XForms instances at runtime in a Firebug console. But the solution had some shortcomings:
- you needed to run on Firefox with Firebug plugin to see the instances
- it was not obvious to users that you had to add a ‘?debug’ to the form URI to get the buttons
- and worst it did not show the instances of embedded models as these could change at runtime
The new solution still requires that you activate the ‘debug’ feature in the betterform-config.xml but is now independent of Firefox and Firebug. Once activated a bar is rendered at the bottom containing one link to see the host DOM as it exists on the server (pre-transform) as well as one link for each instance in each model. The links update if a model becomes available by embedding or is removed from the document by unloading.
The XForms inspector can now be collapsed to an icon to avoid hiding elements on the page.
we now implement the proposal for the dialog element along with its show and hide actions.
There is a new XFormsPostServlet to allow initialization of a XForms from a http POST containing xforms markup in the body.
XForms Feature Explorer / Reference
The XForms Feature Explorer serves as a live reference for XForms and betterFORM. It has been completely overhauled and given a clean structure with description (with spec links), live example and source code. Alongside of that you will see which CSS classes that apply in the respective context and can even see them at work when hovering the class name. New sample forms have been added beyond the basic control and container documentation.
Here is a screenshot of one reference form:
Automatic CSS import for subforms
CSS style rules that are present in a document that is embedded will now get imported into the embedding document. Currently only style elements are handled but this still allows usage of external CSS files by using the @import instruction.
Refined user agent configuration
The betterform-config.xml now allows to configure a new user agent along with its supporting Java class and a XSLT transform.
The handling of resource pathes has been simplified. Instead of having multiple pathes for CSS, scripts etc. there’s now only one for the resource root dir which is configurable in betterform-config.xml.
The XPath processor is now using Saxon 188.8.131.52.
Http Client update
The http client has been upgraded to latest version of HttpComponents (formely Apache Commons HttpClient).
Java code level logging has been refined in many areas now giving you more fine-grained control on the level of detail you’d like to log. Instead of just ‘debug’ we are now making use of the ‘trace’ level which produces much better readable output.
Configurable delay for incremental
Each control may now have an additional delay for the firing of incremental events. If delay is 0 there will be one event for each keypress while a control has focus. A bigger value will defer the firing for the specified time in milliseconds.
Refined alerts and hints
The default behavior for alerts and hints has been reworked. As the default now inline alerts and hints will be used. Hints will show when a control gets focus. Whenever a control gets invalid the alert will show in the same place as the hint (covering it). Alerts can be closed by clicking on them in case they cover other fields in a complex layout. The CSS for these child elements has been stabilized and works with horizontal and vertical layouts.
New alternative date control
There’s a new date control consisting of three dropdown controls instead of the datepicker popup.
Restructured XSLT transforms
The XSLT stylesheets responsible for the transformation from XForms to HTML have been completely overhauled for easier maintainability and extensibility. The base stylesheet now again produces native controls which can be overwritten to add functionality like scripting. As a result the overall stylesheets are more modular, smaller and easier to enhance.
- fixed various problems with stale UI Events leading to repeating alert messages in the browser
- an issue with downloading of schemas from the internet has been fixed (Ticket #40)
- a hard-to-catch race condition with the ajax calls was fixed that only shows under heavy test conditions. Now the client-side uses a fifo buffer to make sure all events are processed in right order and even is able to discard events that may have become irrelevant in the meantime through network delays.
- the style attribute was not handled correctly in all places. This is fixed now. (Ticket #28)
- some issues regarding focus events (especially group and repeat focus events) have been addressed.
- fixed naming inconsistencies of betterFORM CSS classes (Ticket #26)
- fixed a problem with loosing trailing zeros during localization
- Issue with betterform-index-changed events fix (Ticket #74)
- fixed trailing zero problem for internationaized values (Ticket #73)
- added missing xfValue class to triggers (Ticket #19)
- fixed missing xforms-in-range event for select control (Ticket #48)
- clarified issue with potential CSRF attacks in Tomcat 7 (Ticket #30)
- clarified issue with Weblogic 10.3 (Ticket #81)
- fixed broken Rating control (Ticket #39)
- fixed problem with alert in secret elements (Ticket #66)
- fixed problem with sum() function working on invaid nodes (Ticket #61)
- fixed issue when ehcache is not configured properly (Ticket #103)
- re-introduced xfRequiredEmpty class that signals required but empty fields after a submission error (Ticket #110)
- slider problems in IE9 have been fixed (Ticket #140)
- a problem with large localised decimals has been fixed (Ticket #150)
- a problem with setting of context params has been fixed (Ticket #139)
- plus several dozens of minor changes
- a problem with the context() function has been fixed (Ticket #29)
- a problem with the validation on long decimals has been fixed (Ticket #150)
- handling of upload in eXist integration has been fixed (Ticket #133)
- a problem with ‘selection=open’ has been fixed (Ticket #116)
- broken DOMFocusIn handling has been fixed (Ticket #156)
- @value on Element value not working was fixed (Ticket #42)
- SSL now may use Java provided keystone (Ticket #154)
- event() function not evaluating has been fixed (Ticket #146)
- namespace in submitted instance now behave spec-conformant (Ticket #130)
- selection=”open” in repeats now works correctly (Ticket #157)
- enhanced / fixed handling of HTTP headers
- fixed problem with setfocus action not setting the focus in some situations
- enhanced error information for exceptions
- upgraded to Xerces 2.11
- fixed ranges within repeats (Ticket #201)
- fixed missing support for choice labels (Ticket #195)
- fixed problem with dependant lists in IE8 (Ticket #192)
- fixed escaping problem with entities (Ticket #193)
- fixed problem with params on instance @src attributes (Ticket #189)
- fixed bug with positioning of tooltip alerts (Ticket #198)
- added a TimePicker implementation (Ticket #178)
- fixed issue with html default namespace
The WordPress.com stats helper monkeys prepared a 2011 annual report for this blog.
Here’s an excerpt:
The concert hall at the Syndey Opera House holds 2,700 people. This blog was viewed about 17,000 times in 2011. If it were a concert at Sydney Opera House, it would take about 6 sold-out performances for that many people to see it.
A while back we wrote about a new XForms editor as part of our post ‘What’s new in betterFORM limeGreen’. Now it’s about time for an update as we have a first working beta running and it’s ready for testing by the community.
Before this questions comes up – no, it’s not WYSIWYG and likely never will be. We’ve been working with XForms for many years and our experience showed that it’s not the layout and styling that are the challenges in XForms authoring. In contrast – concentrating on this aspect just draws the attention away from the more challenging aspects of building XForms.
XForms offers an abstraction layer for developing complex forms with constraints, calculations, events, actions, submissions and a dynamic UI that ignores the concrete rendering of a control on a device. And we think there should be an editor that supports this abstract view.
It must be confessed that XForms is not easy to master – especially not for the beginner. You have to learn a set of elements, attributes, know at least the basics of XPath, understand XML Events and namespaces and learn to assemble all that in a meaningful manner. You also have to understand some basic concepts like the MVC, the lifecycle, bindings etc. and finally write all that down without typos in your favorite text editor. Wouldn’t it be good to at least have a little help with some of these aspects?
To achieve consistency with the XForms Schema we decided to generate big parts of the editor directly from the schema. This makes sure that all elements and attributes are present and supported.
The editor can be started directly from the betterFORM dashboard. Clicking the editor icon next to the filename this will be opened in the editor.
The following screen will appear.
The loaded document is a XHTML/XForms document but HTML elements are not shown. Instead the editor focusses on the XForms elements and shows them in a hierarchical view of boxes where each box represents an element in the document. However HTML markup will not be discarded by the editing process – it will be preserved and will still be part of the output document.
On the right side all possible attributes for the element are shown and can be edited. In the current early version these attributes are not sorted and do not offer any help. This will change in later versions – we plan to add hint and help texts that give some explanations about the attributes. Further we’ll introduce some sorting of the attributes depending on the frequency of their use.
The currently selected element will show 3 buttons on the right side:
- one for inserting sibling elements
- one for inserting child elements
- and one to delete the current element
This screenshot shows the context menu for inserting elements.
For efficient use the whole editor can be driven by keyboard: elements can be navigated and re-sorted, new elements can be inserted or deleted and there is a popup window listing the most important shortcuts.
The current version is still basic and may contain bugs. But it’s functional and the commands ‘preview’, ‘save’ and ‘save as’ are working. Currently we concentrate on eliminating the last bugs, offer support for templates and improve the handling of mixed content which is sometimes still shown though it does not break the editors functionality.
Though already a big help for users that do not want to deal with the naked markup this version is still targetted at developers. A future version for end users will offer different modes to create a form. We keep you posted.
If you’d like to try what we got you have to checkout and build the development branch on GitHub. Instruction on building are found here. However if you like to have a online presentation please send a notice to info at betterform dot de and we’ll arrange a session for you.
Comments and suggestions welcome.
One area where we give ourselves in the hand of technology is air traffic. As soon as we enter an airplane we have to trust a complex machinery and hope that machines, pilots and ground personal are doing their job right and bring us safely back to the ground. But flying does not only involve airplanes and well-trained pilots but mountains of data about airports, airspaces, run ways, weather conditions etc. etc.
A important acronym in this domain is ATM which stands for ‘Air Traffic Management’. Two of the most important organizations in air traffic are the Federal Aviation Association (FAA) and Eurocontrol. Together both organizations developed a conceptual model of the whole aeronautical domain and also offer an implementation of that model in XML Schema. This is the technological foundation for Aeronautical Information Services (AIS) that allow the digital exchange of data between all relevant parties.
However it takes more than a schema to build an application. The schema describes all the entities, objects and their relationships and it’s up to the software vendors to build complete solutions from that. All the data that are needed to ensure a high level of safety in the operation of air traffic must be entered by humans and those need good user interfaces to do their job. The gathered information is then used on-flight to give pilots up-to-date information about outages, special conditions at certain airports, restricted airspaces and so forth.
This is where XForms comes into play. The aforementioned schema consists of about 4 megabytes of schema definitions and about 150 ‘features’ and same amount of ‘objects’ as they are called in this model. These ‘features’ and ‘objects’ can then be combined with each other, nested within each other and linked to other ‘features’ and ‘objects’. All this happens at runtime when ground operators build complex messages from the available set of entities.
Though clean from a conceptual view this highly dynamic model puts heavy burdens on the engineers and eliminates any possibility to build static user interfaces to support all types of messages. Fortunately the authors of XForms decided to build it upon XML and as such it is ideally suited to be generated from a formal description such as a XML Schema.
The application described here was build by a leading vendor of Air Traffic Control (ATC) solutions.Their engineers have choosen a SOA approach to provide maximum flexibility and connectivity with other applications. In the backend a large Oracle database is used to store all the collected data. The whole user interface for collecting and maintaining the data is generated from the XML Schema resulting in about 300 separate XForms documents using several dozens of custom datatypes. Each form comes with its own template instance which represents one entity from the schema. Those template instances are then aggregated at runtime to build a certain message to be stored in the database.
The necessary aggregation of instances and associated user interfaces was a problem that couldn’t be solved elegantly with XForms 1.1. The key to success was a tiny extension to XForms allowing forms to be embedded in already loaded ones. With an additional value ’embed’ for the attribute ‘show’ of the XForms load action and an attribute ‘targetid’ this extension is only a very small addition to the language set of XForms. Here’s an example:
<xf:load show="embed' targetid="foo"> <xf:resource value="'myResource'"/> </xf:load>
This extension has already been proposed for XForms 2.0 which is currently under development.
Additional challenges had to be met: we needed a way to exchange instance data of a subform with their respective ‘master’ and to allow to ‘mount’ some piece of data into the master instance to build a complete messages. We developed several solutions to this that do not break the encapsulation of the target model but discussion of the details is left to another blog post. Further we had to find a user interface presentation that allows an operator to keep the overview over a complex document. To solve this we implemented a tabbed control behaving like a XForms repeat – for each loaded subform a tab is dynamically added and shows the respective subform within it. An additional breadcrumb navigation helps to keep track of the hierarchy in the document. Last but not least the instance data of a stored message are not allowed to contain empty nodes. Thus when loading a stored message for editing the data had to be merged with their template instances. This was solved with a XSLT transform to be executed whenever a message was read from the web-service layer of the database.
After heavy and serious testing the customer was able to deliver the first implementation of the standard worldwide which is now in production use in several countries. Soon after first release the generative approach proved itself valuable as the application needed to be migrated to a new XML Schema version. With a single excecution of the XForms generator the new forms were available and could be used right away.
We think this project is an impressive example of the power of XForms. To summarize the facts:
- 300 generated XForms documents
- about 50 custom datatypes
- a highly dynamic user interface embedded inside of a portal
- about 4 megabyte of raw XML Schema data using about a dozen of different namespaces
- massive use of optional elements
- all forms connected to SOAP web-services
- running in a standard web browser without any plugins
- not a single line of script code was necessary to implement the forms
The XML Summer School is now using the eXist XML database and betterFORM for their trainings. They have setup a demo application which allows the students to experience the power of XML. Here’s a screenshot of this application:
The teaching application itself is Open Source and can be downloaded from sourceforge.