expath-pkg


Implementations of the EXPath Packaging System

NEW: The install of the Packaging System repository manager and its support for Saxon and Calabash is easier, thanks to a graphical installer! Just download and execute the file *-install.jar instead of downloading the ZIP file.

The EXPath Packaging System is a system to package, deliver, install and use XSLT, XQuery and XProc libraries. It is defined by its own specification, which defines also a standard repository layout for such packages.

This is an implementation of such a repository, providing a tool to manage it, as well as runtime support for Saxon. Those are provided by the scripts xrepo and saxon. In order to use a repository, you first have to initialize it. Then you can install package within the repository, and use it to resolve libraries from your own stylesheets, queries and pipelines.

To install it, just unzip the distribution file, and go to that directory in the command line (with a Unix shell or the Windows command line). Then set the environment variable SAXON_HOME to point to the directory where you installed Saxon (either in your environement, or by modifying directly the scripts). Then execute the following commands on Unix to create a new repository, install the sample package, and run the sample stylesheet and query which use this package (you will need to create the dir /usr/share/expath first, or adapt the path):

``` $ xrepo create /usr/share/expath/repo

$ xrepo --repo /usr/share/expath/repo install sample/hello-1.0.xar Install module Test package? [true]: Install it to dir [hello]:

$ saxon --repo /usr/share/expath/repo -xsl:sample/test-hello.xsl -it:main Hello, world!

$ saxon --repo /usr/share/expath/repo --xq sample/test-hello.xq Hello, world! ```

or the following on Windows (you will need to create the directory c:/expath first, or adapt the path):

```

xrepo.bat create c:/expath/repo

xrepo.bat --repo c:/expath/repo install sample/hello-1.0.xar Install module Test package? [true]: Install it to dir [hello]:

saxon.bat --repo c:/expath/repo -xsl:sample/test-hello.xsl -it:main Hello, world!

saxon.bat --repo c:/expath/repo --xq sample/test-hello.xq Hello, world! ```

If you want to use the same repository everytime you execute Saxon from the command line, set the environment variable EXPATH_REPO to the repository directory, and both xrepo and saxon will use this value as a default if you don't explicitely call them with the option --repo. For example the following is the equivalent of the above Unix commands, providing that the variable EXPATH_REPO has been set to /usr/share/expath/repo:

``` $ xrepo create /usr/share/expath/repo

$ xrepo install sample/hello-1.0.xar Install module Test package? [true]: Install it to dir [hello]:

$ saxon -xsl:sample/test-hello.xsl -it:main Hello, world!

$ saxon --xq sample/test-hello.xq Hello, world! ```

If you cannot use those Unix and Windows scripts, the equivalent Java commands are the following (the scripts do a bit more job, but this is the equivalent of the above simple commands):

``` $ java -jar pkg-repo.jar create /tmp/repo

$ java -jar pkg-repo.jar --repo /tmp/repo install sample/hello-1.0.xar Install module Test package? [true]: Install it to dir [hello]:

$ java -Dorg.expath.pkg.saxon.repo=/tmp/repo \ -cp .../saxon9.jar:resolver.jar:pkg-repo.jar:pkg-saxon.jar \ net.sf.saxon.Transform \ -init:org.expath.pkg.saxon.PkgInitializer \ -xsl:sample/test-hello.xsl \ -it:main Hello, world!

$ java -Dorg.expath.pkg.saxon.repo=/tmp/repo \ -cp .../saxon9.jar:resolver.jar:pkg-repo.jar:pkg-saxon.jar \ net.sf.saxon.Query \ -init:org.expath.pkg.saxon.PkgInitializer \ sample/test-hello.xq Hello, world! ```

There are also Java classes to configure Saxon when it is used directly from within a Java application. Ask the EXPath mailing list if you want more info on that subject.

You can call xrepo and saxon with the option help to get help about more options. If you have more questions or remarks, or if you find any bug, please use the EXPath mailing list. This implementation of the EXPath repository is hosted by Google Code, where you can find sources, distribution files and doc.

``` $ xrepo help
Usage: xrepo [--repo |--verbose] help|list|install|remove|create|lookup ...

Commands: help list install [-b|-f] -b batch operations (no interaction) -f override a package if already installed (force) remove [-b] -b batch operations (no interaction) create lookup ```

For reference, here is the sample stylesheet, which uses the stylesheet packaged in the sample package. Note how it references it in xsl:import, by using only an absolute URI (this is not a location anymore, this is a unique name):

```

```

The sample query is the following. It does not use any location hint (the at clause in the import statement), only the target namespace of the library module to import:

``` import module namespace h = "http://www.example.org/hello";

{ h:hello('world') } ```

Project Information

Labels:
expath xpath xquery xslt xproc packaging