<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 Presto. 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
ParallelService (
parallel.emml) for an example of merging multiple results
See
Mashup Samples for a list of
Presto mashup samples and where to find them.