Xforms-action-error

From W3C XForms Group Wiki (Public)
Jump to: navigation, search

PROPOSED CHANGE

The script Element

This action is used to execute a script. The script may either be embedded inline or may be imported from an external file using the src attribute.

Common Attributes: Common, Events, Action Common

Special Attributes:

type
The attribute type specifies the language of the script. Its value must be a valid MIME type. The supported languages depend on the XForms processor (an implementation may choose to support no languages at all). It is an xforms-action-error with error-type script-language-not-supported if the action is executed and the languages is not supported.
src
Author-optional attribute src identifies an external resource that provides the script implementation. If the link traversal fails, it is treated as an exception (The xforms-link-exception Event).
charset
Author-optional attribute charset specifies the encoding of the remote resource identified by the src attribute.

If the src attribute is given, then it takes precedence over inline content, and the script implementation for the script is obtained from the link. If the src attribute is omitted, then the script implementation for the script is obtained from inline content.

It is an xforms-action-error with error type script-execution-error if the action is executed and an error occurs during the execution of the script.

The XPath in-scope variables, the current context item, position and size are made available to the script as variables following the best practices for the specific scripting language. For example, in JavaScript, they can be made available as namespaced variables using the following format: XForms.var.{variable-name}, XForms.context.item, XForms.context.position and XForms.context.size.


Script action
<script type="text/javascript">
  foo();
</script>

The xforms-action-error Event

Dispatched as an indication of an error while executing an action.

Note:

Currently only the script action uses this event, but in the future other action may dispatch this notification event in error conditions.

Target: Action elements

Bubbles: Yes

Cancelable: No

Context Info:

Property Type Value
error-type string One of the following: script-language-not-supported, script-execution-error.
error-message string An implementation-specific string that should contain a description of the error.
Default Action: None; notification event only.