Living documents with XML events (1/4) - exploring XML
Living documents with XML events
Most documents today are living documents in the sense that they are constantly updated and never finished. With the advent of HTML and Web browsers documents became also living in that they can interactively respond to events. Now this kind of life comes to XML documents with the newly standardized XML event handling...
An event is the manifestation of some asynchronous happening associated with an element in an XML document, such as a mouse click on some text element, or an arithmetical error in the value of an attribute, or one of many other possibilities.
In the DOM event model, an event is dispatched by passing it down the document tree in the capture phase to the element where the event occurred (called its target). Subsequently it then may be passed back up the tree again in the bubbling phase. In general an event can be responded to at any element in the path (an observer) in either phase by causing an action, and/or by stopping the event, and/or by cancelling the default action for the event at the place it is responded to.
Where there are events, actions, handlers, and listeners cannot be far:
- An
action
is some way of responding to an event; - A
handler
is some specification for such an action, for instance using scripting or some other method. - A
listener
is a binding of such a handler to an event targetting some element in a document.
HTML binds events to an element by encoding the event name in an attribute name, such that the value of the attribute is the action for that event at that element. This method has two main disadvantages: firstly it hardwires the events into the language, so that to add a new event, you have to make a change to the language, and secondly it forces you to mix the content of the document with the specifications of the scripting and event handling, rather than allowing you to separate them out.
Therefore the XML approach is slightly different...
Produced by Michael Claßen
Created: Nov 12, 2001
Revised: Nov 12, 2001