What is simplest way to make the same function available in two xqm modules?

Wednesday, 14 May 2014 · 2 messages
MB
Michel Banguerski14 May 2014 16:11 #

Greetings,

I have two xqm files (located in webapp folder) and would like to define a function that could be used in both of them.

What would be the most simple approach? For example is it possible to call is it possible to call a function defined in one xqm file from another?

TIA Best regards Michel

DK
Dirk Kirsten14 May 2014 16:41 #

Hello Michel,

sure. I would recommend to add all xqm files which are used by multiple files to be put into the repository, see https://docs.basex.org/wiki/Repository for more information (you can just put them into the repo/ folder, no need to use the commands).

Based on the namespace URI, BaseX will automatically search for the xqm file in the repository when importing it like that:

import module namespace mymodule = 'your-uri';

However, you do not have to do that and you can explicitly point to the xqm location:

import module namespace mymodule = 'your-uri' at '/location/to/file.xqm';

Either way, you can now use the function within the module, e.g. mymodule:mysupercoolfunction()

Cheers, Dirk

Quoted text · Michel Banguerski · 14 lines
On 14/05/14 16:11, Michel Banguerski wrote: > Greetings, > > I have two xqm files (located in webapp folder) and would like to define > a function that could be used in both of them. > > What would be the most simple approach? > For example is it possible to call is it possible to call a function > defined in one xqm file from another? > > > TIA > Best regards > Michel
-- Dirk Kirsten, BaseX GmbH, http://basex.org |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22

⚡Generated with XQuery