|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] If Statements within an If Statement?Michael Kay mike at saxonica.comWed Apr 2 22:43:16 PST 2008
As far as I can see your syntax is OK and your if expression should always return something. If it doesn't return anything, then perhaps it isn't being executed, which could be because your FLOWR expression is selecting no tuples. Of course, you haven't provided enough information for me to test it, and the fact that I can't see an error when scanning it by eye doesn't mean that there is no error. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: http://x-query.com/mailman/listinfo/talk > [mailto:http://x-query.com/mailman/listinfo/talk] On Behalf Of Wei, Alice J. > Sent: 02 April 2008 21:20 > To: http://x-query.com/mailman/listinfo/talk > Subject: If Statements within an If Statement? > > Hi, XQueriers: > > This may be a simple problem, but it appears that I have > either missed something or have problems figuring out what a > certain function means. > > Here is my function: > > declare function local:searchresult($seq as element()*) as > element()* { > > let $a := > collection("my")//ad//address[contains(upper-case(.),$search)], > $b := collection("my")//ad//p[contains(upper-case(.),$search)], > $c := collection("my")//ad//address[contains(upper-case(.),$search5)], > $d := collection("my")//ad//p[contains(upper-case(.),$search5)] > > let $sorted_result:= > for $doc in distinct-values($seq) > order by $doc > return $doc > for $d at $count in $sorted_result > let $head := $seq[.=$d][1]/ancestor::ad//child::head[1] > let $head2 := $seq[.=$d][1]/ancestor::ad//child::head[2] > let $head3 := $seq[.=$d][1]/ancestor::ad//child::head[3] > let $para := $seq[.=$d][1]/ancestor::ad//child::p > order by $d > return > <div><p>Showing Result: <b>{$count} / > {count($sorted_result)}</b></p> <p > style="font-weight:bold">{$head}  {$head2}  > {$head3}</p> <p>{$para}</p> </div> }; local:searchresult($a union $d > > I would like to have this so that it can say something like > > return > > if (count($sorted_result) lt 1) > then <p>Sorry, no results retrieved.</p> else if > (count($sorted_result) gt 200) then <p>Sorry, too many > results returned.</p> else <div><p>Showing Result: > <b>{$count} / {count($sorted_result)}</b></p> <p > style="font-weight:bold">{$head}  {$head2}  > {$head3}</p> <p>{$para}</p> </div> > > My problem is > > (1) When I tried to do a count of the result in the first if > statement, it does not even show anything. (Is this another > XPath problem?) > (2) Is this syntax accurate? > > Any suggestion is appreciated. > > Alice > ====================================================== > Alice Wei > MIS 2008 > School of Library and Information Science Indiana University > Bloomington http://x-query.com/mailman/listinfo/talk > > _______________________________________________ > http://x-query.com/mailman/listinfo/talk > http://x-query.com/mailman/listinfo/talk
|
Purchase Stylus Studio Online Today!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






