XML Scripting (E4X)

Although the MagooClient validating XML editor provides all of the functionality required to edit XML documents, there are a whole range of user tasks which require a more dynamic approach to manipulating XML content. Examples include:

  • Creating macros to manipulate the contents of XML messages. For instance, summing up individual items to create a total and then calculating sales tax.

  • Applying additional validation rules. Although XML Schema provides a powerful capability to validate individual fields it cannot be used to check complex relationships between fields. Therefore the ability to create more sophisticated logic to test for error conditions within a document is required.

  • Dynamic validation and populating of form fields using external callouts. A critical aspect of many tasks involving XML messages is utilizing external data sources or services to obtain dynamic data sets. A mechanism is therefore required to dynamically invoke on Web Services and use the response data to populate or validate message content.

These tasks require the ability to quickly and easily create customized business logic to support more sophisticated XML processing. Scripting languages such as JavaScript, PHP and VBScript allow developers to rapidly create powerful macros which greatly enhance document-handling within Web pages and spreadsheets. With E4X (ECMAScript for XML) this scripting approach can now be applied to XML.

 

ECMAScript for XML, defined by the ECMA standards body, is a set of programming language extensions which add native XML support to JavaScript. E4X adds native XML datatypes to the ECMAScript language, extends the semantics of familiar ECMAScript operators for manipulating XML objects and adds a small set of new operators for common XML operations, such as searching and filtering. It also adds support for XML literals, namespaces, qualified names and other mechanisms to facilitate XML processing.

 

MagooClient Scripting Support

MagooClient embeds the popular Mozilla Rhino scripting engine, an open-source JavaScript (ECMAScript) implementation with full E4X support. MagooClient supports interaction with the Rhino engine by providing:

  • An integrated script editor to allow developers create and modify E4X scripts,

  • Automatic synchronization between script input/output and XML message contents. This allows developers to test scripts directly on message instances and view the results including any validation errors.

  • A set of built-in JavaScript objects to support user interaction between scripts and the MagooClient environment. These include a dialog object to allow alert and selection message boxes to be created for user interaction as well as an HTTP request object to support the sending of Web Service requests to external services.

  • JavaScript code-generation to automatically create script code for accessing nodes within an XML message and creating SOAP requests for external Web Service invocation.