Subject:Newbie Xquery problem to solve Author:Roger Powell Date:04 Jan 2005 12:02 PM
I copied this example from the XQuery book by Michael Brundage (Addison Wesley). Page 14, fig 1.7
I have added variable declarations (missing from the book) and a different namespace declaration.
StylusStudio gives the error message: "Variable my:n does not exist."
But my:n is declared inside the argument of my:fact -- not correct?
I also get errors if I try to declare the variable (globally) outside the argument.
The example, copied verbatim, also gives errors.
(: Sample version 1.0 :)
declare namespace my = "http://www.brunel.ac.uk/~emstrsp";
declare function my:fact($my:n as xs:integer) as xs:integer
{
if ($my:n < 2)
then 1
else $my:n * my:fact($my:n-1)
};
declare variable $ten as xs:integer := my:fact(10);
<table>{
for $i in 1 to 10
return
<tr>
<td>10!/{$i}! = {$ten div my:fact($i)}</td>
</tr>
}</table>
Subject:Re: Newbie Xquery problem to solve Author:(Deleted User) Date:04 Jan 2005 03:41 PM Originally Posted: 04 Jan 2005 03:35 PM
Hi Roger,
what you are hitting is a bug in the XQuery processor, triggered by the
fact that the variable definition is invoking a user-defined function that
hasn't been fully constructed.
A fix for this problem will be available in the upcoming 6.1 release.