Changes

Jump to navigation Jump to search
1,535 bytes added ,  23:30, 24 June 2011
no edit summary
==Introduction==
The functionality of a 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 a XQuery processor with packages. BaseX offers an implementation of this mechanism based on the [http://expath.org/spec/pkg specification] created by [http://expath.org/ EXPath].
==What is a package?==
===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 an .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:
 
<pre>
expath-pkg.xml
functx/
functx.xql
functx.xsl
</pre>
 
In case you want to extend BaseX with a java library, some additional requirements have to be fulfilled:
 
* Apart from the package descriptor <code>expath-pkg.xml</code> the package has to contain at its root a descriptor defining the included jars and the binary names of the public classes from them. It has to be named basex.xml and has to have the following structure:
 
<pre class="brush:xml">
<package xmlns="http://www.basex.org/pkg">
 
<jar>...</jar>
 
....
 
<class>...</class>
<class>...</class>
....
 
</package>
</pre>
 
* The jar file itself along with an XQuery file defining wrapper functions around the java methods has to reside in the module directory. The following example illustrates how java methods are wrapped with XQuery functions:
 
'''Example:'''<br>Suppose we have a simple class <code>Printer</code> having just one public method print():></br>
administrator, Bureaucrats, editor, reviewer
41

edits

Navigation menu