Chapter 8. Support of EXPath Packages

Table of Contents

1. Installing EXPath Packages
1.1. Installation in Qizx Server
2. Using Packages in Qizx

Qizx 4.2 introduces support for the EXPath initiative:

Generally speaking, an EXPath Package can simply define XQuery functions or XSLT templates, but it can also be Processor-specific and extend the processor within built-in functions and various add-ons.

In Qizx, a Package can define:

Note that a Package can contain simultaneously all these kinds of resources. So this mechanism allows distributing a whole application in a single Package.

Tip

Qizx Packages can be downloaded from: http://www.axyana.com/expackages.html .

1. Installing EXPath Packages

EXPath Packaging comes with a command-line tool xrepo which performs management tasks for a Repository.

This tool is available in the Qizx distribution at QIZX-DISTRIB/bin/xrepo, a Unix version and a Windows version xrepo.bat .

Get the package(s):

packages come as .xar files.

Create a Package Repository

A Package Repository is a directory where Packages are installed:

> xrepo create myrepository

This command creates a Repository that will be used by applications.

Install a Package
> xrepo --repo myrepository install package.xar
List installed Packages

To check that a package is installed, use the following command:

> xrepo --repo myrepository list
http://example.org/hello-world
  1.0.0, in hello-world-1.0.0
http://expath.org/ns/zip
  1.0.0, in zip-qizx-1.0.0
http://www.functx.com/functx
  1.0.0, in functx-1.0.0

For each package, this command lists its namespace URI, its version and its name.

Remove an installed Package
> xrepo --repo myrepository remove package_namespace

This command will ask for confirmation before deleting the package.

For example to remove the FunctX package:

> xrepo --repo myrepository remove http://www.functx.com/functx

1.1. Installation in Qizx Server

In Qizx Server, there is an EXPath Repository defined by default:

If Qizx_Server_Root is the server storage directory, then the EXPath Repository is located at Qizx_Server_Root/xpkg_repository.

> xrepo --repo Qizx_Server_Root/xpkg_repository install package

This location can be changed in the configuration of the server (qizx-server.conf).

Notice that adding a package is currently manual and requires a restart of the Qizx server to be taken into account.

Security issues:

Some packages needs to load Jar files dynamically (from the package contents). This might be prohibited by the Servlet Container's security policy. This is a system- and configuration-dependent issue that cannot be addressed here.

2. Using Packages in Qizx

As of version 4.2, Packages are supported in Qizx Studio and the command-line tool qizx.

To run Qizx Studio or qizx using a Repository, use the -xrepo option:

qizxstudio -xrepo my-repository arguments...
qizx -xrepo my-repository arguments...

An alternative is to set the environment variable EXPATH_REPO to the (absolute) path of the Repository.

 

Using XQuery Modules from Packages:

Reminder: in XQuery, a module is imported through a namespace URI that is resolved by the XQuery processor in an "implementation-dependent" way. In addition, it is possible to specify location hints, that may help the processor to effectively locate the XQuery module.

For example, if the Packaging system were not used, one could have to specify a location explicitly, which is cumbersome and not portable:

import module namespace zip = "http://expath.org/ns/zip" at "wherever/zip.xq"; 

zip:entries('sample.zip')

The purpose of EXPath Packaging is precisely to define a method for importing modules that is independent of any implementation.

Therefore the module import only uses the Namespace URI specific to the module. The Packaging system is in charge of resolving this URI by looking for a mapping inside the package.

Thus we would write:

import module namespace zip = "http://expath.org/ns/zip"; 

zip:entries('sample.zip')