MashZone NextGen 10.2 | Appendix | Legacy Presto components | Mashables and Mashups | Mashups in EMML | Writing Mashups in EMML | Combining Component Mashable or Mashup Results | <merge> | <merge> Examples
 
<merge> Examples
<merge> Basics
You identify the variables to merge in inputvariables as a comma-separate list. You must also identify the outputvariable to receive the merged results.
This example shows a simple merge of results from three syndicated web feeds whose results are in that same format:
<variables>
<variable name="YahooRSS" type="document"/>
<variable name="FinancialNewsRSS" type="document"/>
<variable name="ReutersRSS" type="document"/>
<variable name="FinanceNewsUnion" type="document"/>
</variables>
...
<merge inputvariables="$YahooRSS, $FinancialNewsRss, $ReutersRSS"
outputvariable="$FinanceNewsUnion"/>
When the names of root nodes are different, the MashZone NextGen Server uses the root node from the first input variable as the root for the merged output. With input variables like this:
<input name="data1" type="document">
<Service1Data>
<firstname>foo1</firstname>
<lastname>bar1</lastname>
</Service1Data>
</input>
<input name="data2" type="document">
<Service2Data>
<firstname>foo2</firstname>
<lastname>bar2</lastname>
</Service2Data>
</input>
<merge inputvariables="$data1, $data2" outputvariable="$result"/>
The result from the merge would look like this:
<Service1Data>
<firstname>foo1</firstname>
<lastname>bar1</lastname>
<firstname>foo2</firstname>
<lastname>bar2</lastname>
</Service1Data>
Selecting Specific Nodes from the Merged Results
You can also optionally set the select attribute with an XPath expression that identifies the specific nodes from the input variables to include in the merged results. This next example shows the use of the select attribute to include only invoice items from two database mashables:
<variables>
<variable name="CorpInvoices" type="document"/>
<variable name="DeiboldInvoices" type="document"/>
<variable name="InvoicesUnion" type="document"/>
</variables>
...
<merge inputvariables="$CorpInvoices, $DeiboldInvoices"
outputvariable="$InvoicesUnion"
select="/invoices/invoice/items/item"/>
Normalizing Merged Results for Syndicated Feeds
When syndicated feeds have results in different standard formats, you can normalize all the inputs and then merge the results. You use the feedtype attribute to define the standard feed format for the results and optional title, description and author attributes to provide information about the result.
In this example, three web feeds in three different formats (RSS 2.0, RSS1.0 and Atom 1.0) are merged to the RSS 2.0 format:
<variables>
<variable name="YahooRSS2" type="document"/>
<variable name="FinancialNewsRSS1" type="document"/>
<variable name="ReutersAtom" type="document"/>
<variable name="FinanceNewsUnion" type="document"/>
</variables>
...
<merge inputvariables="$YahooRSS2, $FinancialNewsRss1,
$ReutersAtom" feedtype="rss_2.0" title="Combined Financial News"
description="Yahoo, Reuters and CNN financial news feeds"
outputvariable="$FinanceNewsUnion"/>
Working Samples
The following sample mashups use the <merge> statement: variables
*FeedAggregationSample (merge.emml)
*UnionSample (mergenodelists.emml)
*VariableScopingRules (variables.emml)
See Mashup Samples for a list of MashZone NextGen mashup samples and where to find them.

Copyright © 2013-2018 | 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