Integrate Software AG Products Using Digital Event Services 10.4 | Integrate Software AG Products Using Digital Event Services | MashZone NextGen Help | Appendix | Legacy Presto components | Mashables and Mashups | Mashups in EMML | Writing Mashups in EMML | Creating a Mashup Script with EMML
 
Creating a Mashup Script with EMML
A mashup script is an XML file that uses the Enterprise Mashup Markup Language (EMML). They define the mashable information sources and other information sources to be used by a mashup and the actions to apply to this data to construct the results of the mashup.
Mashup scripts can be very simple, invoking a single mashable information source and filtering the output for example. They also support virtually any level of complexity.
This task discusses how to write a mashup script in EMML using the Mashup Editor. If your MashZone NextGen license supports this, you can also create mashups that use EMML extensions for the Real-Time Analytics Query Language.
You can also use any XML editor with the EMML schema in MashZoneNG-install/mashupclient/schema/EMMLSpec.xsd. If you need to use MashZone NextGen extension elements, such as <presto:presto-meta>, you should use the MashZone NextGen EMML Extensions schema in MashZoneNG-install/mashupclient/schema/EMMLPrestoSpec.xsd.
To create a mashup script using EMML
1. Start a new mashup in the Mashup Editor:
a. Select DATA SOURCES > Mashup Editor in the MashZone NextGen Hub main menu.
The Mashup Editor opens with a new mashup script already started. If the Mashup Editor is already open, simply click New to open a new tab for a new mashup.
b. Change the name in the <mashup> tag to the logical name for this mashup.
Commonly, this matches the mashup’s name in MashZone NextGen, although that is not required.
Note: MashZone NextGen uses the mashup name to assign a unique identifier to the mashup. Mashup names can contain characters from the character sets supported by theMashZone NextGen repository, numbers, spaces, tabs, line ends and these common symbols: _ ~ - * ' .
2. Add EMML elements directly to invoke mashables or mashups, call macros, define variables and perform actions to define the mashup result. Use the Mashables, Mashups, Macros and Actions menus to add EMML elements. Declare any namespaces that are used in the script on the <mashup> element.
The elements that you add to mashups are either:
*Declarations for variables, parameters, data sources, namespaces, macros or metadata.
*Statements that perform actions for the mashup. This includes statements to invoke mashables or other mashups, control flow, act on the results or use custom statements defined in macros.
For
Use These Elements or Attributes
*<variables>: contains one or more <variable> definitions to hold the input or output for any mashup script statement.
*<input>: defines an input parameter for this mashup.
*<output>: defines the name and type for the result of this mashup.
Previous versions of EMML also used <inputparam> and <outputparam>. These declarations are deprecated.
xmlns attribute on <mashup> or <macro>: declares a namespace used by:
*A mashable information source called in the mashup.
*Macros called in the mashup. See Calling a Macro for more information.
*MashZone NextGen extension statements. See EMML Namespaces for the namespace you must declare when you use MashZone NextGen extensions such as <presto:presto-meta>.
*Parameters or variables constructed with literal XML.
The <namespaces> element is deprecated.
<datasource>: defines connection information to one database for use with direct SQL statements in this mashup. You can also simply used named datasources defined in MashZone NextGen.
*<invoke>: invokes the operation for a published MashZone NextGen mashable information source.
*<directinvoke>: Invokes an ungoverned, publically accessible web service or web site. Only HTML, Syndicated Feeds, REST web services and SOAP web services are supported.
*<sql>: to execute SQL queries to a datasource.
*<sqlUpdate>: to execute any other SQL statement to a datasource.
*<sqlcall>: to execute a stored procedure for a datasource.
*<assign>: copies, and optionally transforms, one variable or variable fragment to another variable. This uses XPath 2.0 expressions to identify the source nodes to copy and optionally applies XPath functions to transform the result.
This statement can also be used to assign literal values.
*<filter>: filters a set of nodes in a variable based on a filter expression in XPath 2.0.
*<group>: find unique values, and optionally filter, a set of repeating nodes in a variable. This constructs a result document based on those groups. This statement supports multiple levels of grouping and calculations on groups.
*<sort>: sorts a set of nodes in a variable based on sort keys and a sorting expression in XPath 2.0.
*<annotate>: adds attributes or children elements to a selected node of a variable and assigns values using an XPath expression. This is typically used to add data to the mashup result or an intermediate variable.
*<script>: defines a script to execute at runtime at the specified location in mashup processing. You can include JavaScript scripting code directly or point to an external file with any supported scripting language on the local server.
The MashZone NextGen Server supports JavaScript and Groovy as scripting languages inside mashup scripts. Scripting can also access any Java class in the classpath.
*<xslt>: process an input document using an XSLT stylesheet to tranform and construct a result document.
*<join>: joins the results of two or more mashable information sources or other mashups based on a join condition. This element works like a database join, where the results may be disparate but must have key nodes that determine how data is joined. You can also define the structure and nodes to include in the result of the join.
*<merge>: merges the results of two or more mashable information sources or other mashups that have homogenous result models. The element works like a database union. The results of all services must have identical structures.
*<constructor>: creates a structure for the result of this mashup or for an intermediate variable. You define the nodes of the result and use mashup expressions to define the data from a variable to fill these nodes.
*<appendresult>: appends a structure of nodes to the result of this mashup or to an intermediate variable. This is typically used in repeating loops to handle results with repeated sections.
You define the nodes of the structure to append and use mashup expressions to define the data from a variable to fill these nodes.
*<select>: creates a structure for the mashup result or for an intermediate variable with only selected nodes from a repeating set of items.
See also <join> with a <select> child and <group>.
*<if>: handles if-elseif-else processing for a mashup script based on a condition defined in XPath 2.0. You can include any mashup statements in any section of <if>.
*<for>: processes a loop of any mashup statements based on a sequential count.
*<foreach>: processes a loop of any mashup statements either iterating sequentially through each node in a set of nodes from a variable or processing each loop concurrently. The set is an XPath 2.0 'sequence' defined by an expression.
*<while>: processes a loop of any mashup statements as long as a condition is true. The condition is defined in a XPath expression.
*<break>: explicitly stops processing the current loop and all subsequent loops in <for>, <foreach> or <while>. This can be used in <if>, <elseif> or <else> when they are used within looping statements.
*<try>: to execute a block of EMML statements and catch and handle any exceptions from those statements.
*<throw>: to throw an exception for this mashup or macro. If this exception is not caught in a <catch> block in this mashup or macro, this also forceably stops mashup/macro processing.
*<return>: to forceably stop mashup or macro processing and return the current value of <output> as the mashup or macro result.
*<macro>: defines a custom EMML statement for use in mashups. Macros can contain any mashup statements. They accept input parameters and can return a result in an output variable.
*<macros>: root node for a macro library containing one or more macro definitions for use in any mashup hosted by a MashZone NextGen Server. See also Creating and Registering Macros.
*Calling a Macro using the custom statement <macro:custom-macro-name> in a mashup script.
*<display>: sends debugging messages to the log and console, optionally including the value of a variable or a portion of a variable.
*<assert>: defines assertions that are evaluated at runtime. Failures throw exceptions.
*<emml-meta> for metadata built into EMML
*<presto:macro-meta> for metadata for macros that are used as custom blocks in Wires or used solely in mashups written in EMML
*<presto:presto-meta> for metadata built into MashZone NextGen
*<user-meta> for custom metadata to meet your requirements
Working with large datasets using RAQL
See Getting Started with MashZone NextGen Analytics and RAQL Queries for more information on the EMML extensions you can use with large datasets and RAQL.
For example:
<mashup name="NewsStories"
xmlns="http://www.openmashup.org/schemas/v1.0/EMML"
xsi:schemaLocation="http://www.openmashup.org/schemas/v1.0/EMML/
../xsd/EMMLSpec.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:macro="http://www.openmashup.org/schemas/v1.0/EMMLMacro"
xmlns:presto="http://www.jackbe.com/v1.0/EMMLPrestoExtensions">
<variables>
<variable name="stories" type="document"/>
</variables>
<output name="result" type="document"/>
<invoke service="YahooRSSFeed" operation="getFeed"
outputvariable="stories"/>
<filter inputvariable="stories"
filterexpr="$stories/rss/channel/item[matches(description,'Business')]"
outputvariable="result"/>
</mashup>
3. Once the mashup is complete:
a. Test the mashup. See Test Mashup Scripts or Macros in Mashup Editor for instructions.
b. Click Save As to save, and optionally publish, your mashup script:
*Enter a Name for the mashup. MashZone NextGen uses the mashup name to assign a unique identifier to the mashup. Mashup names can contain characters from the character sets supported by theMashZone NextGen repository, numbers, spaces, tabs, line ends and these common symbols: _ ~ - * ' .
*Optionally, enter a Description for the mashup.
*Optionally, enter Tags or select the Provider for the mashup.
*If the mashup is not yet ready for other users, clear the Publish option. Set this option to turn the mashup on and allow other users to work with it.
*Click Save.

Copyright © 2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Innovation Release