This article is part of the [[XQuery|XQuery Portal]].
It describes how existing external XQuery packages can be installed in the system's repositoryand used from XQuery, and how newpackages can be built.
BaseX supports the [http://expath.org/modules/pkg/ EXPath Packaging API].
Since {{Version|7.2.1}}, we provide additional, easier ways to deployfurther simplifyexternal the deployment of XQuery modules and Java codeclasses.
==IntroductionMotivation==
The functionality One of an XQuery processor can be extended with a variety the reasons why languages such as Java or Perl have been so successful is the vast amount of librariesthat are available to developers. ThisXQuery is a Turing complete language, howeverbut it just provides around 100 pre-defined functions, becomes often a difficult task as there which cannot live up to all expectations. This is no common defined installation process why more and different more libraries comply with different rulesarise – such as [http://www.xqueryfunctions. EXPath addresses this problem by creating a generic mechanism for extending an XQuery processor com/ FunctX] – that extend the language with packagesnew features.
BaseX offers an implementation of this mechanism based on two mechanisms to make new packages accessible to the [httpXQuery processor://expath.org/modules/pkg/ specification] created by [http://expath.org/ EXPath]. A package is a {{Mono|.xar}} archive encapsulating one or more extension libraries. In BaseX, packages may also contain Java libraries which will be called from an XQuery wrapper module.
* The [http://expath.org/modules/pkg/ EXPath Packaging System] provides a generic mechanism for extending XQuery processors with new packages.A package is defined as a {{Mono|.xar}} archive, which encapsulates one or more extension libraries. * {{Mark|Since Version 7.2.1}}, we offer a simplified mechanism to directly install XQuery archives and JAR files to the repository. ==CommandsUsage==
All packages are stored in the package repository. The repository is a directory named {{Mono|BaseXRepo}} or {{Mono|repo}}, which resides in your [[Configuration#Home Directory|home directory]].
The installation will only succeed if the package fully conforms to the specification. If you know that your package is valid, you may as well unzip and copy its files directly to the repository, or edit its contents without reinstalling the package.
===UsageQuerying===
Installed packages can be addressed by importing them as ''modules''. Since we have the package repository in which all packages are located, it is sufficient to just specify the namespace of a module: