I want to do something like:
for $var in $myValueOfVar
return
if ($var= "X") then
<tagA>A</tagA>
<tagB>B</tagB>
<tagC>C</tagC>
else
<tagD>D</tagD>
}
But I get the following error:
Invalid expression, expecting ELSE, found '>'
So I tried to use 4 if
's, one for each tag, as below:
for $var in $myValueOfVar
return
if ($var= "X") then
<tagA>A</tagA>
else
()
if ($var= "X") then
<tagB>B</tagB>
else
()
if ($var= "X") then
<tagC>C</tagC>
else
()
if ($var != "X") then
<tagD>D</tagD>
else
()
}
But I get the following error:
Invalid expression: unexpected token: if
What is the correct way to do this? I found no example following this line.