Bookmark and Share Share

<annotate>

This statement adds attributes or children nodes to node(s) of a document-type variable. Each added node is defined in text within the body of <annotate> in the form:

[element | attribute] name value

Both the name and value of attributes or children can be a static or dynamic expressions. Separate multiple annotation definitions with commas.

Can Contain

The specific syntax for annotations.

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

Attributes

Name Required Description
variable yes

The required input variable for this statement.

expr yes

The relative path within the input variable to the node to be annotated.

<annotate> Examples

<annotate> Basics

You must identify the variable you want to work with and use an XPath expression to identify the specific node(s) within that variable to annotate.

<annotate variable="$distributionLists" expr="/lists/list" > 
</annotate>

Then define the annotations within the body of <annotate>.

Define a New Child

Use the element keyword and a dynamic mashup expression to set its value. For example:

<annotate variable="$vendors" expr="/vendor/site" > 
  element category { "metals" } 
</annotate>

New children are always appended after any existing children.

Define Children with Namespaces

You can also specify a namespace for new children nodes using the QName(namespace) function. For example:

<annotate variable="$payload" expr="/*:books/*:book" > 
  element {QName("http://www.books.com/xmlns", "review")} 
    { "Five stars!" } 
</annotate>

Note: you must use the syntax for dynamic element names when specifying a namespace.

The namespace parameter for QName() should be a URL or URN. If this namespace is not the same namespace as the node being annotated, the child node that is added also has an xmlns attribute added with this namespace.

Define a New Attribute

Use the attribute keyword and a dynamic mashup expression to set its value. For example:

<annotate variable="$distributionLists" expr="/lists/list" > 
  attribute corporate { "yes" } 
</annotate>

Set Names or Values Dynamically

Both the name and the value for new attributes or elements can be set dynamically in Dynamic Mashup Expressions. The result of the dynamic expression must evaluate to a simple value. For example:

<annotate variable="$vendors" expr="/vendor/site" > 
  element geo:lat { $georesult//y:Latitude/string() }, 
  element geo:long { $georesult//y:Longitude/string() } 
</annotate> 
<annotate variable="$distributionLists" expr="/lists/list" > 
  attribute server { $emailServers/servers/server/name } 
</annotate> 
<annotate variable="$notifications" expr="/notification" > 
  attribute { $property } { $colorScheme } 
</annotate>

Make Multiple Annotations to the Selected Variable and Nodes

You can apply several annotations to the selected variable and targe node(s). Separate multiple annotations with commas. For example:

<annotate variable="$vendors" expr="/vendor/site" > 
  element geo:lat { $georesult//y:Latitude/string() }, 
  element geo:long { $georesult//y:Longitude/string() } 
</annotate>