At 2010-05-19 19:07 +0530, Pragya Kapoor wrote:
>I have a query regarding the if-else statement in query.the code
>below describes the query:
>
>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
>
>Now if there is a entry with entryid=1 then it gives $entry2=2 .
>whereas if no entry exists with entryid=1 then it gives "no
>results". Please suggest me some other way to check the if condition
>so that I can get the desired result.
You don't say what your desired result is, but I'm guessing you want
$entry2 if there are no entries as desired:
let $entryid:="1"
let $entry1:="1"
let $entry2:="2"
return if (empty(doc("uri")//root/ent...@id=$entryid]))
then
$entry1
else
$entry2
I hope this helps.
. . . . . . . . . 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