I read eXist Documentation (part of it, actually) but I didn't found out =
how to make external xQuery functions libraries.
I use eXist as main database for a PHP-XML CMS. I access it through the =
webservice with SOAP.
There are some xQuery functions I have developped and that I use many =
times. And up to now, I've always copy them on each XQuery file I need =
them... Not very nice...
I read in the documentation, that :
"A library module is basically just a collection of function definitions =
and global variable declarations. eXist knows two types of modules: =
external modules which are themselves written in XQuery, and internal =
modules implemented in Java. The standard XPath/XQuery functions and all =
extension functions described above are defined through internal =
But I can't find other informations about that famous external xquery =
I just want to store some of my xQuery functions in ONE single file and =
load that file whenever I need it. How can I do that ? Where should I =
store the file ? How can I import the file into my other XQuery file ?
Thank you for your response !
Ps: I'm using the last snapshot.
From: Wolfgang Meier <wolfgang@ex...> - 2005-03-01 18:24:46
> I just want to store some of my xQuery functions in ONE single file and
> load that file whenever I need it. How can I do that ? Where should I
> store the file ? How can I import the file into my other XQuery file ?
If you are using a newer snapshot, there's an elegant way to share code
between queries: put your functions into a library module and upload it
to the database. A library module is a file that starts with "module
namespace prefix='uri';" and contains just function and variable
For example, if you put your functions into the module file
"mymodule.xq", you can upload it to the database collection /db/modules
bin/client.sh -m /db/modules -p mymodule.xq
(Don't use the GUI: it puts a wrong mime-type on the uploaded doc. I
fixed that today. Stored XQuery modules have to have the mime-type
Now if you declared the module namespace in "mymodule.xq" as:
module namespace my="mymodule";
you can import it into your XQuery (the one you send over SOAP) like this:
import module namespace my="mymodule"
and use the functions in this module by prefixing the function names
with "my:". The URI part "xmldb:exist:" tells the XQuery engine that the
module should be loaded from the database, not the file system or the