XML events

from Wikipedia, the free encyclopedia

XML Events is a specification of the W3C to events that occur in an XML document, to handle. These events are typically triggered by a user who interacts with the document, a website, with the help of an Internet browser on a PC, mobile phone or telephone.

Formal definition

From a technical point of view, an XML event is the representation of an asynchronous process (e.g. a mouse click on a button) to which any data element in an XML document is assigned. XML events provides a static, syntactic link to the DOM events interface, which means that the event can be processed.

Motivations

The XML Events standard was defined to give XML-based languages ​​a way of integrating uniform observers and associated event handlers in Document Object Model (DOM) Level 2 event interfaces. The result is an explanatory, interoperable method of associating behavior with XML-based documents, such as XHTML .

Benefits of XML Events

XML Events uses a separation of concerns design template, and its technology is very neutral thanks to handlers . In this way, website designers are given freedom in terms of code organization and a separation of document content and script is also possible.

Both earlier HTML and earlier versions of SVG associate elements with a presentation element by encoding the event name into an attribute name. Thus the value of the attribute is also the action for the event of the element. For example (with the onclick attribute):

<p>Bleib <a href="http://www.beispiel.com" onclick="window.alert('Hallo!'); return false;">hier</a>!</p>

This design has three disadvantages:

  1. The events are language tied so you have to change the language to add a new event type
  2. It forces software developers to mix the content of a document with the scripting and event handling specifications instead of allowing separation
  3. You can only use one script language per document.

Relationship to other standards

In contrast to events in the DOM , which according to the specification are permanently linked to the respective HTML document, XML events were designed to be completely independent of the displaying or processing device. XML events are used extensively in XForms , as well as in version 1.2 of the SVG specification.

Example of XML events using listeners in XForms

The following is an example of how XML events are used using listeners in the XForms specification:

<html
   xmlns="http://www.w3.org/2002/xhtml"
   xmlns:ev="http://www.w3.org/2001/xml-events"
   xmlns:xf="http://www.w3.org/2002/xforms">
   <head>
      ...
      <ev:listener event="DOMActivate" observer="meinButton"
          handler="#doit"/>
   </head>
   ...
</html>

In this example, the handler doit (for example a JavaScript script element) is executed when the DOMActivate event occurs on the data element with the ID attribute meinButton .

See also

Web links