Enterprise IT Consultant Views on Technologies and Trends

Mar 24 2011   6:46AM GMT

Mashup Scripting using EMML from OMA

Sasirekha R Profile: Sasirekha R

Mashup Scripting using EMML from OMA

Open Mashup Alliance (OMA) is a consortium aimed at successful use of Enterprise Mashup technologies and adoption of an open language – Enterprise Mashup Markup Language (EMML) – that promotes Enterprise Mashup interoperability and portability. EMML is an XML language to describe the processing flow for a mashup. The OMA provides the EMML schema and also a reference runtime implementation that processes mashup scripts written in EMML.

The EMML package can be downloaded from http://www.openmashup.org/download. Before installing the EMML package, install the JDK (1.5 or above) and Tomcat 5.5 or another compatible application server. EMML samples can be downloaded from http://www.openmashup.org/download.

You can create a mashup script using any XML editor. Adding the EMML schema, emml-install/EMMLSpec.xsd, to the XML editor – enables the editor to provide syntax assistance and validation. A Mashup script – an XML file that uses EMML – is created to define:

  • the services and operations to be used by the mashup and
  • the actions to apply to service responses to construct the results of the mashup.

Following is a simple mashup script that invokes a service (most viewed stories) and filters the output (business).

<?xml version=”1.0″?>
<mashup name=”NewsStories”
    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” >
    <variable name=”stories” type=”document”/>
  <output name=”result” type=”document”/>
  <directinvoke endpoint=”http://rss.news.yahoo.com/rss/mostviewed”
      method=”GET” outputvariable=”stories”/>
  <filter inputvariable=”stories”

 Two categories of elements are added to mashups:

  • Declarations for variables, parameters, data sources, namespaces, macros or metadata.
  • Statements that perform actions – to invoke services, control flow, act on the results or use custom statements defined in macros – for the mashup.

Variables and Parameters

Variables and parameters must be declared (explicitly or implicitly) before they are used in any other EMML statement. Variables and parameters have a name, a datatype, data (a value), a scope (global or local) and optionally a default value. Variables can be created implicitly by assigning a name to the outputvariable attribute for any statement.

  • <input> is an optional element to declare parameters that can be used as input to mashup, operation or macro.
  • <output> is the parameter that holds the result returned from a mashup, operation or macro.
  • <variables> is a list of variables to use for input, output or to hold any intermediate data or document content in the flow of mashup processing.

Accessing a database

To invoke SQL queries or statements, <datasource> with connection information for the database must be declared.  Each <datasource> declaration must have a URL that defines the JDBC connection and database login information (or) a JNDI name for connections to the database. Connection information can also be set dynamically as follows:

<datasource url=”$system.datasourceURL”
   username=”$system.dbUserName” password=”$system.dbPassword”/>

Note that, to use a <datasource>, you must add the JAR files containing JDBC drivers for your data source to the EMML Reference Runtime Engine classpath and add configuration for these drivers.

Use <sql>to issue individual SQL queries to a data source – for example:

<sql query=”select CUST_ID, CUST_NAME from CUSTOMERS
  where CUST_ID = :customerId” outputvariable=”$customers” />

Use <sqlUpdate> to execute any other SQL statement against a data source – for example:

<sqlUpdate statement=”update credentials set
    user_id = ‘newuser’ where id = ‘1004’”

<sql> and <sqlUpdate> can also be used to invoke stored procedures. SQL transactions can be managed using <sqlBeginTransaction>, <sqlCommit> and <sqlRollback>. EMML currently does not support distributed transactions.

Accessing a Web Service

Using <directinvoke>, you can invoke a publically accessible web service or website. In case of service invocation error, the EMML Reference Runtime Engine returns error information in two built-in variables: faultcode and faultmessage.

Transforming Intermediate Results

The mashup statements that can be used to select specific results, sort results, or otherwise transform the data in variables include:

  • <assign> – to assign values or copy part of all of a variable
  • <filter> – to filter a variable
  • <group> – to group data in a variable and optionally filter or sort
  • <sort> – to sort a variable
  • <annotate> – to add nodes and data to a variable
  • <xslt> – to transform data using XSLT stylesheets

Additionally, XPath functions can be used to transform data, change datatypes, perform calculations or determine boolean conditions.

Using the <script> statement, user-defined code can be executed within mashup processing. JavaScript and JRuby 1.0 are the scripting languages currently supported.

Combining Service Results

Results of two or more component services can be combined using:

1. <merge> – to merge service results that have homogenous, document-type structures (similar to database union operation)

2. <join> – to define how the data from disparate variables should be joined. Variable data should have repetitive structures that are related based on some criteria – say, the foreign keys that define the relation. It is comparable to inner joins for databases.

3. XQuery – to obtain outer joins in mashups.

Constructing the Mashup Result, Input or Intermediate Variables

The following statements can be used to define the structure of the result that is returned from a mashup, or to construct complex input parameters or any complex intermediate variable:

  • <constructor> to construct a well-formed document.
  • <appendresult> to add one or more well-formed items to a variable.
  • <select> (within <mashup>, <operation> or <macro>)
  • <select> within a <join> command to select specific items within a set of repeating items. See <join>.
  • <group> constructs repeating structures from sorted and optionally filtered node sets.

Literal XML can also be used to construct the contents of variables or input parameters.

Controlling Mashup Processing Flow

The mashup commands to control the processing flow for a mashup operation includes:

Using <emml-meta> and <user-meta>, metadata can be declared to allow setting of processing flags or pass other information to applications that will use a mashup, use a macro or handle mashup results.

EMML, like any other tag language, is quite simple to use and can be used by business users to create mashups quickly. EMML also supports various statements and commands that can be used to create complex Mashups depending on the needs of the user.

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: