You are reading O'Reilly XForms Essentials by Micah Dubinko. (What is this?) - Buy XForms Essentials Online

XForms Events

The XML Events specification provides a clean declarative way to call out actions that should be performed under certain conditions. Under what conditions, exactly? That depends on a processing model—including the definition of what events are involved, and when they become active.

At the time of this writing, the topic of XML processing models was still under fervent discussion in various pockets of standards activity, with no obvious end in sight. Each XML specification contains details of its own self-contained processing model, but nowhere is there a description of how different specifications interact or relate to one another. XForms is no different.

An entire chapter in the XForms specification is devoted to the processing model. Much of this material, however, is mainly of interest to programmers who happen to be implementing an XForms support in some product. For form authors, a simpler view is possible.

The life-cycle of an XForms processor can be divided into several categories, which is a useful viewpoint for a form author. By scrutinizing what you want to accomplish, you can narrow down the potentially huge list of events to a more manageable list. Figure 7.3, “Stages of XForms processing” shows the stages of XForms processing.

Inevitably, problems can happen during form processing. XForms defines events for such situations, with each event categorized as either an error, which is recoverable, or an exception,[4] which is serious enough to immediately terminate form processing with a message.

When an error condition occurs, application-specific handling (such as logging) is always a possibility and, in fact, is a good way to investigate problems.



[4] Those with some programming background might think of an exception as something that can be "caught," in order to prevent a terminating error condition. XForms 1.0, however, doesn't provide any means to catch or re-throw an exception, so they're always fatal.