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 | Advanced Mashup Techniques | Making Mashup Scripts Dynamic | Dynamic Mashup Syntax | Define XPath or Other Syntax Using <template>
 
Define XPath or Other Syntax Using <template>
The <template> declaration can be used to dynamically define XPath expressions, portions of XPath expressions, SQL queries, URLs or any string. The <template> result is assigned to a variable which can be used in other EMML statements or passed as a parameter to other mashup scripts. See Dynamic XPath or Other Syntax in Mashups for more information and Escape XML Delimiters Inside <template> Expressions.
This example, defines a dynamic join condition, in the expr attribute, based on two input parameters. The result is assigned to a variable and then used in a <join> statement:
<template expr="{$column1} = {$column2}" outputvariable="$dynamicEqualJoin"/>
<join outputvariable="joinResult" joincondition="$dynamicEqualJoin"/>
The next example shows <template> used to build a dynamic SQL query based on input parameters which is then used in a <sql> statement:
<input name="offense" type="string" />
<input name="method" type="string" />
<input name="numrows" type="number" default="10" />
...
<variable name="sqlquery" type="string"
default="select * from crime where 0=0 " />
...
<if condition="$offense != ''">
<template expr="{$sqlquery} and offense = '{$offense}'"
outputvariable="sqlquery"/>
<elseif condition="$method != ''">
<template expr="{$sqlquery} and method = '{$method}'"
outputvariable="sqlquery"/>
</elseif>
</if>
<template expr="{$sqlquery} limit 0,{$numrows}" outputvariable="sqlquery" />
...
<sql name="DCCrime2008" query="$sqlquery" outputvariable="result"/>

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