Difference between revisions of "Repository"

From BaseX Documentation
Jump to navigation Jump to search
(Created page with "==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 ...")
 
Line 1: Line 1:
 
==Introduction==
 
==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 EXPath.
+
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?==
 
==What is a package?==
Line 6: Line 6:
  
 
===Structure===
 
===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>

Revision as of 22:30, 24 June 2011

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 specification created by EXPath.

What is a package?

A package is a .xar archive encapsulating one or more extension libraries. The implemntation of BaseX currently supports extension with XQuery libraries and java libraries packed as .jar files.

Structure

The EXPath specification defines how the structure of a .xar archive shall look like. The package contains at its root a package descriptor named expath-pkg.xml. 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 FunctX XQuery Library is packaged as follows:

expath-pkg.xml
functx/
   functx.xql
   functx.xsl

In case you want to extend BaseX with a java library, some additional requirements have to be fulfilled:

  • Apart from the package descriptor expath-pkg.xml 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:
<package xmlns="http://www.basex.org/pkg">

   <jar>...</jar>

    ....

   <class>...</class>
   <class>...</class>
    ....

</package>
  • 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:
Suppose we have a simple class Printer having just one public method print():>