MashZone NextGen 10.2 | Appendix | Legacy Presto components | Mashables and Mashups | Mashups in EMML | Writing Mashups in EMML | Constructing the Mashup Result, Inputs or Intermediate Variables | <constructor> | <constructor> Examples
 
<constructor> Examples
Construct the Complete Document
This is the basic use of <constructor> to define the entire contents of a variable. For example:
<mashup ...
xmlns:svc="http://www.someservices.com/services/catalogService"
xmlns:res="http://www.myCompany.com/myresults">
...
<constructor outputvariable="result">
<res:mailinglist>
<res:displayName>{$filterResult/list/name}</res:displayName>
<res:email>{$filterResult/list/email}</res:email>
</res:mailinglist>
</constructor>
...
<constructor outputvariable="$lookupItem">
<svc:query>
<svc:account>{$acctId}</svc:account>
<svc:item>
<svc:itemnumber>{$itemId}</svc:itemnumber>
<svc:type>UPC</svc:type>
<svc:scope>global</svc:scope>
</svc:item>
</svc:query>
</constructor>
The data to add can be literal text or Dynamic Mashup Expressions to add dynamic data.
Construct the Root and Append Repeated Content
If you need to fill a variable with a set of repeating data, you must still wrap this in a root node. To handle this scenario, you can use <constructor> to add the root node and <appendresult> to fill in content.
For example:
<mashup ...
xmlns:res="http://www.myCompany.com/myresults">
...
<constructor outputvariable="$result">
<res:comments/>
</constructor>
...
<foreach variable="comment"
items="$calls//customerCall/comment">
<appendresult outputvariable="result">
<res:comment>
<res:customer>{$comment//custom/name/string()}</res:customer>
<res:report>{$comment//description}</res:report>
</res:comment>
</appendresult>
</foreach>
Working Samples
The <constructor> statement is used in many of the sample mashups for MashZone NextGen. Some of particular interest include:
*ErrorHandlingSample (onerror.emml) for a basic example
*MacrosSample (macros.emml) and SOAPService (soapservice.emml) for examples of contructing requests
*LeftOuterJoinSample (outerjoin.emml) for an example of constructing and executing an XQuery query
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