[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?

Wei, Alice J. ajwei at indiana.edu
Wed Apr 2 16:59:05 PST 2008


  If Statements within an If Statement?
Hi, David and Michael:

  What is interesting is that when I put only one function out as I have had before, it brings me the appropriate result from the return.
  Currently, I have many similar patterns of such function, only its element calls may be different (which was why I ran into problems with union and intersect operators)

   If I modify my function call to this, then the problems of why I started posting here reappear.

declare function local:main($search as xs:anyAtomicType*) as element()*
{
let $a := collection("my")//ad//address[contains(upper-case(.),'BOY')],
$b := collection("xmldb:exist://db/cbml")//ad//p[contains(upper-case(.),'GIRL')]

return

local:searchresult(($a union $b) intersect ($a except $b))

};

declare function local:searchresult($seq as element()*) as element()*
{
let $a := collection("my")//ad//address[contains(upper-case(.),'BOY')],
$b := collection("my")//ad//p[contains(upper-case(.),'GIRL')]

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/descendant::head[1]
let $head2 := $seq[.=$d][1]/ancestor::ad/descendant::head[2]
let $head3 := $seq[.=$d][1]/ancestor::ad/descendant::head[3]
let $para := $seq[.=$d][1]/ancestor::ad/descendant::p
let $pb := $seq[.=$d][1]/preceding::pb[1]
order by $d
return
if (count($sorted_result) lt 1)
then
<p>Sorry, too many results returned. Please refine your search to have them displayed.</p>
else if (count($sorted_result) gt 200)
then
<p>Sorry, there are no results retrieved back. Please check for your input. </p>
else
<div>
<p>Showing Result: <b>{$count} / {count($sorted_result)}</b></p>
<p style="font-weight:bold">{$head}&#160; {$head2}&#160; {$head3}</p>
<p>{$para}</p>
</div>
};
let $a := collection("my")//ad//address[contains(upper-case(.),'BOY')],
$b := collection("my")//ad//p[contains(upper-case(.),'GIRL')]
return
local:main(collection(my")//ad)

The number of results got returned is 0, which is accurate, but it does not give me any output of what I have had here:

if (count($sorted_result) lt 1)
then
<p>Sorry, too many results returned. Please refine your search to have them displayed.</p>

Is this something I should be doing? Or, is there some syntax errors I have here?

Thanks again for your help.

Alice
======================================================
Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.