Living documents with XML events (3/4) - exploring XML
Living documents with XML events
Attaching to the Observer
All the attributes from the
listener element with the exception
id may be used as global attributes, to attach the
attributes to other elements.
This means that the
<listener> element is,
strictly speaking, redundant, since the following
<anyelement ev:event="activate" ev:observer="button1" ev:handler="#click"/>
would have the same effect as the earlier example.
Attaching to the Handler
If, when attaching the global attributes to an element, the
handler attribute is omitted, then the element that the other
attributes are attached to is the handler element.
Note that, since the
are IDREFs, in this case the handler and observer/target elements must be in the
same document (while in other cases, since the
handler attribute is
a URI, the handler element may be in another document).
observer attribute is also omitted, then the parent of
the handler element is the observer element.
<script> element is the handler for event
<img> element is the observer:
The following table summarizes which elements play the role of observer or handler if the relevant attribute is omitted.
|Handler present||Handler omitted|
|Observer present||(As declared)||Element is handler|
|Observer omitted||Element is observer||Element is handler|
Parent is observer
This specification does not require an XML application that uses XML Events
to use any particular method for specifying handlers.
It is however recognized that two methods are likely to occur often:
scripting (such as HTML's
<script> element) and declarative markup using
XML elements (such as WML's
<onevent> element). A companion specification
will provide markup to support these methods.
Naming events is also left to the individual application.
Produced by Michael Claßen
Created: Nov 12, 2001
Revised: Nov 12, 2001