XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Agustín BonilloSubject: Import Modules.
Author: Agustín Bonillo
Date: 16 Jun 2004 02:46 PM
Hello, I have got a problem with "import modules".

I have got create a module with the sintax: (in file modulo.xquery)

module namespace match = "hola";

declare function local:funcion1() as xs:string*
{
.......
};




I have got create a xquery file with the sintax:

import module namespace b = "hola"
at "file://d:\pr\xquery\modulo.xquery";

<prueba>
{
for $prueba in b:funcion1()
return
<pr>
{string($prueba)}
</pr>´
}
</prueba>

When I run this Xquery file, Stylus Studio say:

"Stylus Studio has encountered a problem and needs to close.
We are sorry for the inconvenience."

Why happens it???

I would thank for any aid.


Postnext
Alberto MassariSubject: Re: Import Modules.
Author: Alberto Massari
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.

Thanks,
Alberto


Postnext
Agustín BonilloSubject: 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.

How I can resolve this problem???

I will be pleased if somebody could help me.

Postnext
Alberto MassariSubject: Re: Import Modules.
Author: Alberto Massari
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").

Alberto


Postnext
Agustín BonilloSubject: 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"

Postnext
Agustín BonilloSubject: Re: Import Modules.
Author: Agustín Bonillo
Date: 21 Jun 2004 12:14 PM
Sorry,in the previous Message, the namespace is "http://www.ModuloFunciones" instead of "hola".

Postnext
Alberto MassariSubject: Re: Import Modules.
Author: Alberto Massari
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")

Alberto


Posttop
Agustín BonilloSubject: Re: Import Modules.
Author: Agustín Bonillo
Date: 22 Jun 2004 09:47 AM
Thanks You very much Alberto. You have helping me.

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.