Table of Contents
Qizx 4.2 introduces support for the EXPath initiative:
EXPath defines a generic mechanism for extending a XQuery processor with Packages (in fact EXPath defines Packages for XSLT2 and XProc processors too).
Packages are self-contained, easily deployable extensions to XML processors.
EXPath proposes a few standard Packages: zip-file handling functions, HTTP-client API etc.
EXPath's aims at defining and offering a standard set of API's for XQuery application development, and to extend it gradually.
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:
a set of XQuery functions (i.e an XQuery Module).
For example Priscilla Walmsley's FunctX library has been packaged in such a way.
XSLT templates
Built-in XQuery functions:
Such modules contain code that plug new built-in extension functions.
For example the EXPath zip module is provided with a Qizx-specific implementation.
Add-ons:
For example, Qizx 4.2 provides a module html5-importer which allows importing HTML5 documents. either in XQuery or through the Java API.
Other content importers will be available in future versions: csv, Mime mail etc
Note that a Package can contain simultaneously all these kinds of resources. So this mechanism allows distributing a whole application in a single Package.
Qizx Packages can be downloaded from: http://www.axyana.com/expackages.html .
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 .
packages come as .xar files.
Official source for Qizx Packages: http://www.axyana.com/expackages.html .
CXAN, a common repository for EXPath packages: http://cxan.org/
NB: CXAN is not always up-to-date.
A Package Repository is a directory where Packages are installed:
> xrepo create myrepository
This command creates a Repository that will be used by applications.
> xrepo --repo myrepository install package.xar
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.
> 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
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.
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.
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 -xrepomy-repository
arguments
...
qizx -xrepomy-repository
arguments
...
An alternative is to set the environment variable EXPATH_REPO to the (absolute) path of the Repository.
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')