XQuery syntax problem

Issues related to W3C XQuery.
R0bin_
Posts: 1
Joined: Sat Oct 28, 2017 3:43 pm

XQuery syntax problem

Post by R0bin_ » Sat Oct 28, 2017 3:46 pm

Hello! Im having some issues figuring out some syntax using an if-if else in an loop. What am I doing wrong? Thanks :D

Code: Select all


{for $programme in $tv/programme
return
<div class="channel_programmes">
<span class="programme_time">
{data($programme/start)}
</span>
<span class="programme_title">
{data($programme/title)}
</span>
let $x := {data($programme/type)};
return
if ($x = 'movie') then
(<span class="movie">Film</span>)
else if($x = 'series') then
(<span class="series">Serie</span>)
else if($x = 'sports') then
(<span class="tvshow">Tv show</span>)
else if($x = 'tvshow') then
(<span class="sports">Sport</span>)
</div>
}
Best regards,
R0bin_

adrian
Posts: 2534
Joined: Tue May 17, 2005 4:01 pm

Re: XQuery syntax problem

Post by adrian » Mon Oct 30, 2017 10:39 am

Hi,

What's the issue?
The snippet is out of context, so the best I can do is this:

Code: Select all

{
for $programme in $tv/programme
return
<div class="channel_programmes">
<span class="programme_time">
{data($programme/start)}
</span>
<span class="programme_title">
{data($programme/title)}
</span>
{
let $x := data($programme/type)
return
if ($x = 'movie') then
(<span class="movie">Film</span>)
else if($x = 'series') then
(<span class="series">Serie</span>)
else if($x = 'sports') then
(<span class="tvshow">Tv show</span>)
else if($x = 'tvshow') then
(<span class="sports">Sport</span>)
else ()
}
</div>
}
I'm assuming $tv is declared somewhere...

PS: You seem to have switched "tvshow" with "sports", but then again I don't know what's the desired result.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Post Reply