Changes

Jump to navigation Jump to search
1,647 bytes added ,  23:45, 24 June 2011
no edit summary
* 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 <code>print()</code>: <pre class="brush:java">package test; public final class Printer { public String print(final String s) { return new Writer(s).write(); }}</pre> We want to extend BaseX with this class and use its method. In order to make this possible we have to define an XQuery function which wraps the print method of our class. This can be done in the following way: <pre class="brush:xquery">module namespace j="jar"; declare namespace p="java:test.Printer"; declare function j:print($str as xs:string) as xs:string { let $printer := p:new() return p:print($printer, $str)};</pre> As it can be seen the class <code>Printer</code> is declared with its binary name as a namespace prefixed with "java" and the XQuery function is implemented using the [http://docs.basex.org/wiki/Java_Bindings Java Bindings] offered by BaseX. ==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 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</brcode> 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.
administrator, Bureaucrats, editor, reviewer
41

edits

Navigation menu