- XML Events
XML Events is a
W3C specification for handling events occurring in anXML document. These events are typically caused by a user interacting with the document as a web page using a device such as a web browser on a PC, mobile phone or telephone.Formal Definition
Technically an XML event is the representation of some
asynchronous occurrence (such as a mouse click on a button) that gets associated with any data element in anXML document. XML Events provides a static, syntactic binding to theDOM Events interface, allowing the event to be handled.Motivation
The XML Events standard is defined to provide XML-based languages with the ability to uniformly integrate
event listeners and associatedevent handlers withDocument Object Model (DOM) Level 2 event interfaces. The result is to provide a declarative, interoperable way of associating behaviors with XML-based documents such asXHTML .Advantages of XML Events
XML Events uses a
separation of concerns design pattern, and is technology neutral with regards to handlers. It gives authors freedom in organising their code, and allows separation of document content from scripting.Both legacy
HTML and early SVG versions bind events to a presentation 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. For example (with the "onclick" attribute):Stay here!
This design has three drawbacks:
# it hard-wires the events into the language, so that to add a new event type, you have to make a change to the language
# it forces software developers to mix the content of the document with the specifications of the scripting and event handling, rather than allowing you to separate them out
# it restricts you to a single scripting language per document.Relationship to Other Standards
Unlike
DOM Events which are usually associated with HTML documents, XML events are designed to be independent of devices. XML Events are also used extensively inXForms , and in version 1.2 of the SVG specification, as of July 2006 still a working draft.Example of XML Events using Listener in XForms
The following is an example of how XML events are used in the XForms specification:
...In this example, when the DOMActivate event occurs on the data element with an id attribute of myButton, the handler doit (for example a javascript script element) is executed.
ee also
*
ECMAScript
*DOM Events
*XForms
*XHTML External links
* [http://www.w3.org/TR/xml-events W3C XML Events Specification] was a [http://www.w3.org/TR/2003/REC-xml-events-20031014/ W3C Recommendation on 14 October 2003]
* [http://www.w3.org/MarkUp/2004/xmlevents-for-html-authors W3C XML Events for HTML Authors] tutorial
Wikimedia Foundation. 2010.