The current version of XML Events allows you to declare a listener for an event on a node. There are multiple ways to do this, but the easiest is to use a global attribute in the events namespace (signified by the prefix ev below):
<xforms:action ev:event="DOMActivate"> ...
An xforms:trigger can be represented, for example, by a button widget, and pressing the button results in a DOMActivate event on the trigger.
The ev:event declares the name of the event to listen for, and the default value for ev:target (when it's not specified) is the parent element of the one containing the ev:event. So, the above declaration causes a listener to be created for the occurrence of the DOMActivate on the trigger. The handler for the event is given by the content of the xforms:action that bears the ev:event. An example of an action to be performed would be inserting a node of data (which would likely correspond to adding a row to a repeat table).
All of this is just plain vanilla XForms so far. But at the W3C tech plenary, the XHTML working group began discussing upgrades to XML events. The reason is that the current version of XML events declares listeners that are created at the moment when the DOM node being listened to is created. There's no way to create a listener later in the life time of a document, possibly contingent on some condition or the occurrence of some event.
Syntax for this could look something like this:
target="X" event="Y" ...
In this example, ev:listener is an action handler for the DOMActivate event that happens on the trigger. So when you activate the trigger (press the button), a listener for event Y is created on the node with id="X".
The local, namespace unqualified attribute 'event' tells the event that the listener will listen for. The global, namespace qualified event 'ev:event' tells the event whose occurrence causes the ev:listener action to be performed.
This is a very neat and compelling example where a local attribute (event) which is given meaning by a namespace (XML Events) might legitimately have a completely different meaning than a global attribute with the same local name and same namespace as the containing element (ev:event).
Although the XHTML working group quite liked this solution, they had a lengthy discussiona and concluded that this aspect of XML namespaces is not understood well enough to rely on the feature without confusing document authors. Of course, they are free to change their minds later, I would say that the above syntax is not likely to see the light of day in a W3C recommendation.
That's why I'm blogging it. Because even if it goes away, we still need to try to increase understanding of this aspect of namespaces and attributes, and nothing does that better than a good example, and this is the first one I've seen.
And we can thank Steven Pemberton for it![Read More]