[xquery-talk] nested if, then, for statements
Michael Kay
mhk at mhk.me.uk
Thu Nov 11 20:50:57 PST 2004
>
> I'm trying to do something like the statement below, but I'm getting
> errors. Do I have the syntax wrong, or do I need to go about it
> completely differently?
>
You have the syntax very wrong!
Firstly, cut out the parentheses after "for".
Then add parens around the condition in an "if".
(Then get yourself a copy of the spec...)
Also, you're trying to use variables as you would in a language that does
textual substitution. This is a common mistake, I think it's because the "$"
signs make them look like shell variables. Use a variable where you would
use a value: collection($coll) rather than collection('{$coll}').
Michael Kay
>
> ======================================
>
> $query := if ($ttl != "")
> then (
> for ($entries in collection('{$collctn}')//TEI.2[.
> &= '*{$kwds}*' and descendant::head &= '*{$ttl}*'])
> (if $entries/@id = "ppp.00271"
> (
> then ...
> )
> else if $entries/@id = "ppp.00237"
> (
> then ...
> )
> else if $entries/@id = "ppp.00473"
> (
> then ...
> )
> else
> (
> ...
> )
> )
> else if (...)
> then ...
> else
> ... ,
>
>
> -----
> - Cindy
>
> Cynthia M. Girard
> IATH, University of Virginia
> clm6u at virginia.edu
>
> "Danger? I laugh in the face of danger!
> ...and then I hide until it goes away."
>
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
>
More information about the talk
mailing list