Changes

Jump to navigation Jump to search
1,525 bytes added ,  00:02, 25 June 2011
no edit summary
==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 [http://docs.basex.org/wiki/Commands_(Snapshot) Commands (Snapshot)]. Here we give just simple examples of their usage and the usage of a package after it is installed.
 
===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:
 
<code>REPO INSTALL /path/to/xar/archive</code>
 
===Using a package===
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:
 
<pre class="brush:xquery">import module namespace functx="http://www.functx.com";</pre>
 
At "seeing" this statement BaseX will check if the namespace "http://www.functx.com" is used in some of the installed packages and if yes, it will load their modules. After that you can call the functions from a module in the standard way, e.g:
 
<pre class="brush:xquery">functx:capitalize-first("test")</pre>
 
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 package===
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.
 
<code>REPO DELETE functx</code>
 
===Listing installed packages===
All currently installed packages can be listes using the REPO LIST command. It will list all packages which currently reside in the repository along with their versions.
administrator, Bureaucrats, editor, reviewer
41

edits

Navigation menu