In
computer science
Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
and
web development, XML Events is a
W3C
The World Wide Web Consortium (W3C) is the main international standards organization for the World Wide Web. Founded in 1994 by Tim Berners-Lee, the consortium is made up of member organizations that maintain full-time staff working together in ...
standard
for handling
events that occur in an
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing data. It defines a set of rules for encoding electronic document, documents in a format that is both human-readable and Machine-r ...
document. These events are typically caused by users interacting with the web page using a device, such as a
web browser
A web browser, often shortened to browser, is an application for accessing websites. When a user requests a web page from a particular website, the browser retrieves its files from a web server and then displays the page on the user's scr ...
on a
personal computer
A personal computer, commonly referred to as PC or computer, is a computer designed for individual use. It is typically used for tasks such as Word processor, word processing, web browser, internet browsing, email, multimedia playback, and PC ...
or
mobile phone
A mobile phone or cell phone is a portable telephone that allows users to make and receive calls over a radio frequency link while moving within a designated telephone service area, unlike fixed-location phones ( landline phones). This rad ...
.
Formal definition
An XML Event is the representation of some
asynchronous occurrence (such as a
mouse button click) that gets associated with a data element in an
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing data. It defines a set of rules for encoding electronic document, documents in a format that is both human-readable and Machine-r ...
document. XML Events provides a static, syntactic binding to the
DOM 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 associated
event handlers with
Document Object Model
The Document Object Model (DOM) is a cros s-platform and language-independent API that treats an HTML or XML document as a tree structure wherein each node is an object representing a part of the document. The DOM represents a document with ...
(DOM) Level 2 event interfaces. The result is to provide a declarative, interoperable way of associating behaviors with XML-based documents such as
XHTML
Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages which mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated.
While HTML, pr ...
.
Advantages of XML Events
XML Events uses a
separation of concerns
In computer science, separation of concerns (sometimes abbreviated as SoC) is a design principle for separating a computer program into distinct sections. Each section addresses a separate '' concern'', a set of information that affects the code o ...
design pattern, and is technology-neutral with regard to
handlers. It gives authors freedom in organizing their code and allows separation of document content from
scripting.
Legacy
Legacy or Legacies may refer to:
Arts and entertainment
Comics
* " Batman: Legacy", a 1996 Batman storyline
* '' DC Universe: Legacies'', a comic book series from DC Comics
* ''Legacy'', a 1999 quarterly series from Antarctic Press
* ''Legacy ...
HTML
Hypertext Markup Language (HTML) is the standard markup language for documents designed to be displayed in a web browser. It defines the content and structure of web content. It is often assisted by technologies such as Cascading Style Sheets ( ...
and early
SVG versions bind events to presentation elements 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
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
’s ''onclick'' attribute):
Stay here!
This design has three drawbacks:
# it hard-wires the events into the
language
Language is a structured system of communication that consists of grammar and vocabulary. It is the primary means by which humans convey meaning, both in spoken and signed language, signed forms, and may also be conveyed through writing syste ...
, so that adding new event types requires changes to the language
# it forces authors to mix the content of the document with the specifications of the scripting and event handling, rather than allowing them to separate them.
# it restricts authors to a single
scripting language
In computing, a script is a relatively short and simple set of instructions that typically automation, automate an otherwise manual process. The act of writing a script is called scripting. A scripting language or script language is a programming ...
per document.
Relationship to other standards
Unlike
DOM Events, which are usually associated with HTML documents, XML events are designed to be independent of specific devices. XML Events are used extensively in
XForms
XForms is an XML format used for collecting inputs from web forms. XForms was designed to be the next generation of HTML / XHTML forms, but is generic enough that it can also be used in a standalone manner or with presentation languages other tha ...
and in version 1.2 of the
SVG specification, , which is still a working draft.
Example of XML Events using a listener in XForms
The following is an example of how XML events are used in the XForms specification:
Do it!
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 element) is executed.
See also
*
ECMAScript
ECMAScript (; ES) is a standard for scripting languages, including JavaScript, JScript, and ActionScript. It is best known as a JavaScript standard intended to ensure the interoperability of web pages across different web browsers. It is stan ...
*
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
*
DOM Events
*
XForms
XForms is an XML format used for collecting inputs from web forms. XForms was designed to be the next generation of HTML / XHTML forms, but is generic enough that it can also be used in a standalone manner or with presentation languages other tha ...
*
XHTML
Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages which mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated.
While HTML, pr ...
References
External links
W3C XML Events Specificationwas
W3C Recommendation on 14 October 2003W3C XML Events for HTML Authorstutorial
{{DEFAULTSORT:Xml Events
World Wide Web Consortium standards
XML