Subject:Re: Import Modules. Author:(Deleted User) Date:16 Jun 2004 06:02 PM
Hi Agustín,
thanks for reporting this bug; the crash happens in the code that imports
the user-defined function into the main query, when the function has no
arguments.
A fix for this problem will be available in the next update of Stylus. In
the meanwhile, you can avoid the crash by adding an argument to the
function definition.
Subject:Re: Import Modules. Author:Agustín Bonillo Date:17 Jun 2004 06:52 PM
Thanks Alberto for your help.
Now, I have got other problem:
I have got a module with two functions:
declare function local:obtener-instituciones-distintas( $e as xs:string) as xs:string*
{
for $institucion in distinct-values(for $documento in doc($documentos)//archivo
for $doc in doc($documento)//fich:ins
return
string($doc/@id))
return
$institucion
};
The following function calls to the previous function.
declare function local:numero-instituciones( $e as xs:string) as xs:integer
{
count(for $institucion in local:obtener-instituciones-distintas("empty")
return $institucion)
};
When I call to the latest function from my Xquery file, Stylus Studio says:
"Function 'obtener-instituciones-distintas' in namespace
'http://www.w3.org/2003/11/xquery-local-functions' is undefined."
If I declare the latest function into Xquery file, there is no problem.
Subject:Re: Import Modules. Author:(Deleted User) Date:18 Jun 2004 09:09 AM
Hi Agustín,
what is happening is that the imported functions are placed in the
namespace of the module (that is, "hola").
So you should change the function definitions to place them in the "hola"
namespace, and be sure that the same prefix is bound to the same namespace
in the main module (both "match" and "b" should point to "hola").
Subject:Re: Import Modules. Author:Agustín Bonillo Date:21 Jun 2004 12:11 PM
Hi Alberto.
I use the same prefix to declare the functions (local) in the module.
The problem is when I call from a function to other function
placed in the same namespace.
When I call from muy xquery file to a function placed in the module "hola",
if the function called calls other function in the same namespace module,
the error appears.
in module:
module namespace match = "http://www.ModuloFunciones";
declare local:funcion1() as xs:string
{
....
}
declare local: funcion2() as xs:string
{
for $i in local:funcion1()
........
}
in Xquery file:
import module namespace m = "http://www.ModuloFunciones"
<results>
{
for $b in m:funcion2()
return
<result>{$b}</result>
}
</results>
The error: "Function 'funcion1' in namespace
'http://www.w3.org/2003/11/xquery-local-functions' is undefined"
Subject:Re: Import Modules. Author:(Deleted User) Date:22 Jun 2004 06:05 AM
Hi Agustín,
when you write a module like the modulo.xquery you wrote, the user-defined
functions should have a prefix that place them in the namespace of the
module, not in the "local" namespace. So the funcion1 and function2 should
be defined (and used) as match:funcion1 and match:funcion2.
The "local" namespace is just a convenient namespace to be used in the main
module only (see §4.12 "In order to allow main modules to declare
functions
for local use within the module without defining a new namespace, XQuery
predefines the namespace prefix local to the namespace http://www.w3.org/2003/11/xquery-local-functions, and reserves this
namespace for use in defining local functions")