I'm new to xquery. Why does the first xquery statement work but the second doesn't? The first has multiple xml elements at the second level and the first has multiple at the top level.
let $payload := <root><foo>bar</foo></root>
return
<root>
{
if (exists($payload/foo)) then
<prop>
<key>mykey</key>
<value>bar</value>
</prop>
else
""
}
</root>
and this doesn't
let $payload := <root><foo>bar</foo></root>
return
<root>
{
if (exists($payload/foo)) then
<key>mykey</key>
<value>bar</value>
else
""
}
</root>