Escape XML Delimiters Inside <template> Expressions
When you build expressions with <template> that use XML delimiters natively in the expression, you need to double-escape XML delimiters. This is required because <template> expressions are evaluated twice to fully resolve expressions.
A common example is building URLs with <template> to use in <directinvoke>. URLs that contain query parameters use the & character to separate the parameter/value pairs. In this case, you need to escape the & character twice to avoid syntax errors. For example:
<template outputvariable="geoCodeEndpoint"
expr="http://maps.google.com/maps/geo?q={$address}&amp;output=xml"/>
<directinvoke endpoint="$geoCodeEndpoint" method="GET"
outputvariable="geocode"/>
The first evaluation resolves &amp; to & which is then properly resolved in the second evaluation when the mashup script is run to &.