  <Query "<%= @query %>">
    Statement "<%= @statement %>"
<% @results.each do |result| -%>
    <Result>
      Type "<%= result['type'] %>"
<%   if result['instance_prefix'] -%>
      InstancePrefix "<%= result['instance_prefix'] %>"
<%   end -%>
<%   if result['instances_from'] -%>
      InstancesFrom <%= Array(result['instances_from']).flatten.map {|entry| "\"#{entry}\""}.join(' ') %>
<%   end -%>
      ValuesFrom <%= Array(result['values_from']).flatten.map {|entry| "\"#{entry}\""}.join(' ') %>
    </Result>
<% end -%>
  </Query>