Changes

Jump to navigation Jump to search
24 bytes removed ,  21:34, 31 January 2012
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 BaseX offers an implementation of this mechanism based on the [http://expath.org/modules/pkg/ specification] created by [http://expath.org/ EXPath]. A package is a Package?==.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.
A ==Package Repository== 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 name and location of your repository might vary.xar archive encapsulating one or more extension libraries BaseX provides three commands for interaction with the package repository – {{Mono|REPO INSTALL}}, {{Mono|REPO DELETE}} and {{Mono|REPO LIST}}. The implementation syntax of these commands is described in [[Commands]]. Since {{Mark|Version 7.1}} of BaseX currently supports extensions with , an additional [[Repository Module]] is available, which can be used to install new packages via XQuery libraries . Here we give simple examples of their usage and java libraries packed the usage of a package after it is installed. ===Installing a Package=== A package can be installed using the {{Mono|REPO INSTALL}} command. The path to the package has to be given as a parameter. An example: {{Mono|REPO INSTALL http://files.basex.org/xar/functx-1.0.xar}} ===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. {{Mono|REPO DELETE http://www.functx.com}} or {{Mono|REPO DELETE functx-1.0}} ===Listing installed packages=== All currently installed packages can be listed using the <code>REPO LIST</code> command. It will list the names of all packages which currently reside in the repository along with their versions: <pre>URI Version Directory-------------------------------------------------------http://www.functx.com 1.0 http-www.functx.com-1.0 1 package(s).</pre>
===Structure===
[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 Repository==
 
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 name and location of your repository might vary.
 
BaseX provides three commands for interaction with the package repository – {{Mono|REPO INSTALL}}, {{Mono|REPO DELETE}} and {{Mono|REPO LIST}}. The syntax of these commands is described in [[Commands]]. Since {{Mark|Version 7.1}} of BaseX, an additional [[Repository Module]] is available, which can be used to install new packages via XQuery.
 
Here we give 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 {{Mono|REPO INSTALL}} command. The path to the package has to be given as a parameter. An example:
 
{{Mono|REPO INSTALL http://files.basex.org/xar/functx-1.0.xar}}
 
===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.
 
{{Mono|REPO DELETE http://www.functx.com}}
 
or
 
{{Mono|REPO DELETE functx-1.0}}
 
===Listing installed packages===
 
All currently installed packages can be listed using the <code>REPO LIST</code> command. It will list the names of all packages which currently reside in the repository along with their versions:
 
<pre>
URI Version Directory
-------------------------------------------------------
http://www.functx.com 1.0 http-www.functx.com-1.0
 
1 package(s).
</pre>
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu