Changes

Jump to navigation Jump to search
171 bytes removed ,  15:31, 13 November 2011
no edit summary
==Introduction==
 
The functionality of an XQuery processor can be extended with a variety of libraries. This, however, becomes often a difficult task as there is no common defined installation process and different libraries comply with different rules. EXPath addresses this problem by creating a generic mechanism for extending an XQuery processor with packages. BaseX offers an implementation of this mechanism based on the [http://expath.org/modules/pkg/ specification] created by [http://expath.org/ EXPath].
==What is a packagePackage?== 
A package is a .xar archive encapsulating one or more extension libraries. The implementation of BaseX currently supports extensions with XQuery libraries and java libraries packed as .jar files.
===Structure===
 
The [http://expath.org/spec/pkg EXPath specification] defines how the structure of a .xar archive shall look like. The package contains at its root a package descriptor named <code>expath-pkg.xml</code>. This descriptor presents some meta data about the package as well as the libraries which it contains and their dependencies on other libraries or processors. Apart from the package descriptor a .xar archive contains a directory which includes the actual XQuery libraries. For example the [http://www.functx.com/ FunctX XQuery Library] is packaged as follows:
[http://files.basex.org/xar/ Here] you can find the FunctX library packaged as a .xar and a sample package containing a .jar file. You can use them to try our packaging API or just as a reference if you want to create your own packages.
==Package repositoryRepository== 
Unzipped packages are stored in the package repository. This is a directory named <code>BaseXRepo</code>, which is located in your home folder. Depending on your [[Configuration]], the location of your home folder varies.
==Interacting with the package repository==Now after you know what is a package and where it is stored, it comes the question how can you install and make use of such packages. BaseX offers three commands for interaction with the package repository - <code>REPO INSTALL</code>, <code>REPO DELETE</code> and <code>REPO LIST</code>. The syntax of these commands is described in [[Commands]]. Here we give just simple examples of their usage and the usage of a package after it is installed. ===Installing a Package===
===Installing a package===
A package can be installed using the <code>REPO INSTALL</code> command. The path to the package on the file system has to be given as a parameter. An example:
<code>REPO INSTALL http://files.basex.org/xar/functx-1.0.xar</code>
===Using a packagePackage=== 
The functionality offered by an already installed package can be used by a module import. Since we have the package repository where all packages reside, it is not needed to indicate the exact place of the module you want to use. It is enough to just import its namespace:
If you want to use a package which encapsulates jar files, you will have to import in the same way the namespace of the module which wraps the java methods and call the XQuery wrapper functions for these methods.
===Deleting a packagePackage=== 
A package can be deleted either by its name or by the name of its directory. This can be done with the command REPO DELETE. e.g.
Bureaucrats, editor, reviewer, Administrators
12,250

edits

Navigation menu