From: Nicola B. <nic...@gm...> - 2006-11-23 15:44:46
|
Hi, I have some doubts with xquery. "if" can only be used inside a for-cycle or inside return? I'dto write an xql files with two targets: 1) show a list of results 2) delete some selected record the target is set by a request parameter. ******************************************************************* xquery version "1.0"; declare namespace transform = "http://exist-db.org/xquery/transform"; declare namespace request="http://exist-db.org/xquery/request"; let $mode := request:get-parameter("mode", "summary") for $j in ( ...collect my nodes ) return if ($mode = "summary") then transform:transform($j,'style.xsl',()) else if ($mode = "delete") then ... ******************************************************************* As you can see if condition is used at the end (return) but in this way for-cycle is always executed, even if I don't need results. I tried to use if like this: +++++++++++++++++++++++++++++++++++ if ($mode = "summary") then [for-cycle] else if ($mode = "delete") then [call function to delete] +++++++++++++++++++++++++++++++++++ , but I got error. Is there a way to do that? Thanx, nico |