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 © 2006-2015 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback