XQuery syntax problem

Issues related to W3C XQuery.
R0bin_
Posts: 1

XQuery syntax problem

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: 2326

Re: XQuery syntax problem

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

Return to “XQuery”

Who is online

Users browsing this forum: No registered users and 0 guests