Bookmark and Share Share

<appendresult>

This statement appends the well-formed document fragment defined in its content to the specified variable. This is commonly used with repeating statements, such as <for> or <foreach>.

The document fragment contains literal XML with static values or dynamic mashup expressions. Elements in the structure should use a namespace, so that they are clearly separated from EMML markup.

Can Contain

Can contain text and any well-formed literal XML.

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

Attributes

Name Required Description
outputvariable yes

The required variable to accept the output of this statement.

<appendresult> Examples

<appendresult> Basics

You set the variable to be updated in outputvariable. With <appendresult>, this variable must already exist. It can be empty or already have a root node to append into. Then define the well-formed content to be added. For example:

<mashup ... 
  xmlns:res="http://www.myCompany.com/myresults"> 
... 
<variables> 
  <variable name="result" type="document"/> 
</variables> 
... 
<foreach variable="$review" items="$reviews//amz:CustomerReviews/amz:Review"> 
  <appendresult outputvariable="$result"> 
      <res:reviewer> 
         <res:name>{string($review//amz:Reviewer/amz:Name)}</res:name> 
         <res:rating>{$review//amz:Rating}</res:rating> 
      </res:reviewer> 
  </appendresult> 
</foreach>

The literal XML content for <appendresult> must be well formed - completely wrapped in a root node. You use literal values or Dynamic Mashup Expressions to define the data that will fill this structure.

Root Nodes for Well-formed Documents from <appendresult>

If the output variable for <appendresult> has a root node already defined, <appendresult> adds repeating items as children of the root node. For example:

<mashup ... 
  xmlns:res="http://www.myCompany.com/myresults"> 
... 
<variables> 
  <variable name="myReviews type="document"> 
    <res:reviews/> 
  </variable> 
</variables> 
 
<foreach variable="$review" items="$reviews//amz:CustomerReviews/amz:Review"> 
  <appendresult outputvariable="$myReviews"> 
      <res:reviewer> 
         <res:name>{string($review//amz:Reviewer/amz:Name)}</res:name> 
         <res:rating>{$review//amz:Rating}</res:rating> 
      </res:reviewer> 
  </appendresult> 
</foreach>

If the variable does not have a root node predefined, <appendresult> adds <xml> as a default root node to ensure the result is a well-formed document.