Bookmark and Share Share

<merge>

Merges the results of two or more variables with a uniform structure or type. The structures of the variables must be identical, except for root node names, and they must be document type variables. Optionally, this can also select specific nodes to be included in the output.

To normalize results for syndication services that you invoke directly, use the feedtype attribute for <directinvoke>.

For more information and examples, see <merge> Basics and Selecting Specific Nodes from the Merged Results.

Can Contain Empty
Allowed In mashup, else, elseif, for, foreach, if, macro, operation, sequence, while,

Attributes

Name Required Description
inputvariables yes

A list of comma-separated input or variable names to use as input to the operation.

outputvariable yes

The required variable to accept the output of this statement.

select  

An expression identifying the specific nodes within the merged result that should be the only nodes included in the output of this statement. This expression must define a well-formed XML structure.

<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 Syndication services:

<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 EMML Reference Runtime Engine 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 services:

<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"/>