Appendix : Legacy Presto components : Mashables and Mashups : Mashups in EMML : Advanced Mashup Techniques : Making Mashup Scripts Dynamic : Generating Mashup Scripts Dynamically : <macro:externalDynamicEMML>
<macro:externalDynamicEMML>
Use the following attributes to define the input parameters for this macro and receive the results:
Attribute
Required
Description
script
yes
A string containing the dynamically generated EMML code to execute.
Mashup scripts that are generated dynamically have these restrictions:
*<input> statements are not allowed as you cannot pass parameters to the mashup.
*Variable access is limited to the variables defined within the generated code. Generated scripts do not have access to variables in the parent mashup.
outputvariable
yes
The name of the variable to receive the results of the generated mashup script.
This variable should be the same type as the expected results of the mashup script. Typically this is a document type.
<macro:executeDynamicEMML> Example
In this use case, data for the mashup comes from several different sources as either web services or from databases. But the access method for a particular data source can change at any given time based on configuration. The mashup uses this configuration to generate a mashup that invokes each data source using the appropriate method:
....
<output name="dynamicResult" type="document"/>
<variables>
<variable name="serviceConfig" type="document"/>
<variable name="dynamicScript" type="document"/>
</variables>
<invoke service="ServiceConfig" operation="getConfig"
outputvariable="serviceConfig"/>
<script type="javascript" inputvariables="$serviceConfig"
outputvariable="$dynamicScript">
<![CDATA[
dynamicScript ="<mashup" +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
"xsi:schemaLocation=\"http://www.openmashup.org/schemas/v1.0/EMML/" +
"../src/schemas/EMMLSpec.xsd\""+
"xmlns=\"http://www.openmashup.org/schemas/v1.0/EMML\"" +
"name=\"myDynamicMashup\">" +
"<operation name=\"getFeed\">" +
" <output name=\"result\" type=\"document\"/>";
if (serviceConfig.serviceA = 'web') {
dynamicScript = dynamicScript +
"<invoke service=\"serviceA\" operation=\"getData\"" +
"outputvariable=\"resultA\" />";
}
//more logic to generate mashup script statements
dynamicScript = dynamicScript +
" </operation>" +
" </mashup>";
]]>
</script>
<macro:executeDynamicEMML script="$dynamicScript"
outputvariable="$dynamicResult"/>
...
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback