Hi,
 
Some good news: the error is triggered by the fact the function get() return an "undefined" variable, like in this example:
<<<
declare namespace fi = "http://www.foo.com";
 
declare function fi:get($E, $B, $N)
{
 $unknown (: generate the error :)
(:  $B :)
};
 
declare function fi:check($a, $B, $L, $E, $N)
{
 let $loc := fi:get($E, $B, $N)
 return
   $loc
};
 
<a> { fi:check(1, 2, 3, 4, 5 )} </a>
 
The execution fails:
 
java net.sf.saxon.Query bugFuncDecl.xq
Syntax error at line 12:
Function get has not been declared
Query processing failed
>>>
 
On the contrary if get() return a initialised variable, it works fine:
<<<
like this:
 
declare function fi:get($E, $B, $N)
{
(: $unknown  generate the error :)
 $B
};
Or like that:

declare function fi:get($E, $B, $N)
{
(: $unknown  generate the error :)
 let $r := 2
 return $r
};
The execution is ok:
 
java net.sf.saxon.Query bugFuncDecl.xq
<?xml version="1.0" encoding="UTF-8"?>
<a>2</a>
>>>
 
So my suggestion are:
 
1) could it be possible to have an error in the get() scope rather that in the check() scope?
2) could it be possible to have a message with a more relevant reason?
 
Kind regards,
Marco
-----Original Message-----
From: Marc Billemaz
Sent: 07 January 2004 10:39
To: saxon-help@lists.sourceforge.net
Subject: RE: [saxon] "Function get has not been declared" error when compiling a Xquery with saxon7-8

Hi Michael,
 
Unfortunately, the fix does not change the behavior of saxon. I pruned the script even more: you should have the following error message now:
>>>
java net.sf.saxon.Query bugFuncDecl.xq
Syntax error at line 28:
Function get has not been declared
Query processing failed
<<<
 
I joined the query with this mail.
 
Again many thanks for your help,
Marco
-----Original Message-----
From: Michael Kay [mailto:mhk@mhk.me.uk]
Sent: 07 January 2004 00:54
To: saxon-help@lists.sourceforge.net
Subject: RE: [saxon] "Function get has not been declared" error when compiling a Xquery with saxon7-8

If Priscilla's suggestion doesn't fix it, please send me the full source.
 
I'm always keen to get examples of cases where error messages aren't as good as they should be, that's the only way I can improve them.
 
Michael Kay
-----Original Message-----
From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Priscilla Walmsley
Sent: 06 January 2004 18:30
To: saxon-help@lists.sourceforge.net
Subject: RE: [saxon] "Function get has not been declared" error when compiling a Xquery with saxon7-8

It looks like in the first line of your function, $Ec should be $Ecu.
 
Saxon seems to generate that message in a variety of situations when there is an error in the function body.  I reported this and I believe Michael fixed it.
 
Hope that helps,
Priscilla
 


From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Marc Billemaz
Sent: Tuesday, January 06, 2004 1:19 PM
To: saxon-help@lists.sourceforge.net
Subject: [saxon] "Function get has not been declared" error when compiling a Xquery with saxon7-8

Hello Michael,

This Xquery:

declare namespace fi = "my_namespace";

(: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 : function fi:get()
 :
 : return
 :
 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :)
declare function fi:get($Ec, $Body, $Num)
{

                if ($Body//@channel = "1") then
                (
                        $as[1]
                )
                else if ($Body//@channel = "2") then
                (
                        if ($as[2]) then ($as[2])
                        else (
                        )
                )
                else if ($Body//@channel = "3") then
                (
                        if ($as[3]) then ($as[3])
                        else (
                        )
                )
                else ( $as )
};

(: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 : function fi:check()
 :
 : return
 :
 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :)
declare function fi:check($a, $Body, $ListStr, $Ecu, $Num)
{
        let $List := fi:get($Ec, $Body, $Num)
Line 40>>return<<
                if (exists($List)) then (
                        for $Na in $List
                        return $Na
                ) else (
                )
};

(: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 : main loop
 :
 :
 :
 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :)
<a>
</a>

Generate an error with saxon7-8 :

<<<
java net.sf.saxon.Query bugFuncDecl.xq

Syntax error at line 40:
Function get has not been declared
Query processing failed
>>>

Though it did not with saxon7-7. I'm really puzzled, and any help is welcome :)

Many thanks,

-- Marco [billemaz@cadence.com]
   Cadence Design Systems
   R&D Paris
   voice +331 3488 5330