At 2010-05-19 07:18 -0700, sai shanker wrote:
>My question is do you really need empty function?

You could use the not() function instead:

let $entryid:="1"
let $entry1:="1"
let $entry2:="2"
return if (not(doc("uri")//root/ent...@id=$entryid]))
then
   $entry1
else
   $entry2

>can 't you say if ($entry) then .... else ....

Not the way you had it, because the way you had it the return clause 
is conditional on there being a $entry ... it will *never* be empty 
(which is what David was trying to tell you):

let $entryid="1"
let $entry1:="1"
let $entry2:="2"

for $entry in doc("uri")//root/entry
where $entry/@id = $entryid
return
if (empty($entry))
then
  $entry1
else
$entry2


I think what you are missing is that the FLWOR expression creates a 
set of tuples and the "return" clause acts only on the tuples 
created.  If you create no tuples, then the "return" clause is not 
invoked.  Your "if ($entry)" attempt is looking at each tuple created 
by the expression ... it isn't looking at the set of tuples.

The way I wrote my expression, the "if" is checking the set of items 
being addressed.

The way you wrote your expression, the "if" is checking each tuple 
member (and when there are no tuples, the "if" isn't even being invoked).

Does this help you understand the situation?

. . . . . . . . . . Ken

--
XSLT/XQuery training:   after http://XMLPrague.cz 2011-03-28/04-01
Vote for your XML training:   http://www.CraneSoftwrights.com/q/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/q/
G. Ken Holman                 mailto:[email protected]
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/q/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to