# The [[#EXPath Packaging|EXPath Packaging]] system provides a generic mechanism for adding XQuery modules to query processors. A package is defined as a {{Code|.xar}} archive, which encapsulates one or more extension libraries.
All modules are stored in the ''repository''. The repository is a directory named {{Code|BaseXRepo}} or {{Code|repo}}, which resides in your [[Configuration#Home Directory|home directory]]. XQuery modules can also be manually copied to the repository directory at runtime.==Importing Modules==
Modules placed in this directory Library modules can be imported with the{{Code|import module}} statement, followed by a freely choosableprefix and the correct namespaceof the target module.The specified location may be absolute or relative; in the latter case, it is resolvedagainst the location (i.e., ''static base URI'') of the calling module.Import module statements must be placed at the beginning of a module:
The following example calls a function from the FunctX moduleMain Module''' <code>HelloUniverse.xq</code>:
<pre class="brush:xquery">
import module namespace functx m = 'http://wwwbasex.functxorg/modules/Hello' at 'HelloWorld.comxqm';functxm:capitalize-firsthello('test'"Universe")
</pre>
Modules can also be imported from anywhere else '''Library Module''' <code>[http://files.basex.org/modules/org/basex/modules/Hello/HelloWorld.xqm HelloWorld.xqm]</code> (in the local file system, as shown belowsame directory):
<pre class="brush:xquery">
import module namespace a m = 'http://example1basex.org/modules/Hello' at "relative.xq";import module namespace b = declare function m:hello($world) { 'http://example2.org/Hello ' at "/absolute/path.xq"|| $world};...
</pre>
In all casesRepository modules are stored in a directory named {{Code|BaseXRepo}} or {{Code|repo}}, which resides in your [[Configuration#Home Directory|home directory]]. XQuery modules can be manually copied to the import statements should be repository directory or installed and deleted via [[#Commands|commands]]. If a modules is placed at in the very beginning of repository, there is no need to specify a location. The following example calls a function from the query file.FunctX module:
The following section will tell you how to install the <pre class="brush:xquery">import module via BaseX [[commands]]namespace functx = 'http://www.functx.com';functx:capitalize-first('test')</pre>
==Command UsageCommands==
BaseX provides three commands for interaction with the package repository: <code>[[Commands#REPO_INSTALL|REPO INSTALL]]</code>, <code>[[Commands#REPO_DELETE|REPO DELETE]]</code>, and <code>[[Commands#REPO_LIST|REPO LIST]]</code>. Packages can also be managed from within XQuery, using the [[Repository Module]].
===Installation===
A module or package can be installed with the {{Code|REPO INSTALL}} command. The path to the file has to be given as a parameter, as the following two examples demonstrate:
REPO INSTALL http://files.basex.org/modules/expath/functx-1.0.xar
REPO DELETE <nowiki>http://www.functx.com-1.0</nowiki>
==Importing Modules== Library modules can also be imported by specifying a location in the module import statement. The path must be relative to the location (i.e.installed, ''static base URI'') of deleted and listed from within XQuery via the calling module: Main [[Repository Module''' <code>HelloUniverse.xq</code>: <pre class="brush:xquery">import module namespace m = 'http://basex.org/modules/Hello' at 'HelloWorld.xqm';m:hello("Universe")</pre> '''Library Module''' <code>[http://files.basex.org/modules/org/basex/modules/Hello/HelloWorld.xqm HelloWorld.xqm]</code> (in the same directory): <pre class="brush:xquery">module namespace m = 'http://basex].org/modules/Hello';declare function m:hello($world) { 'Hello ' || $world};</pre>
==Packaging==