[xquery-talk] if statements within where clauses?

Michael Kay mhk at mhk.me.uk
Wed Jun 14 22:02:00 PDT 2006


> JR> for $a in $doc//author
> JR> where (if ($a/first)
> JR>          then $a/first eq 'Cindy'
> JR>          else true())
> JR>   and (if ($a/last)
> JR>          then $a/last eq 'Girard'
> JR>          else true())
> JR> return $a

As a matter of interest, I think this is equivalent to the XPath 1.0
expression

$doc//author[not(first != 'Cindy') and not(last != 'Girard')]

assuming that "first" and "last" occur at most once.

Michael Kay
http://www.saxonica.com/




More information about the talk mailing list