Database Reference
In-Depth Information
$target
The collection where your package will be installed
The pre- and post-install scripts can be difficult to debug as their output is not visible
to the end user, and errors are logged only when they are very severe (which usually
isn't the case). The advice here is to test them standalone (as much as possible) before
you try them out as part of a package install. If you need to see what your scripts are
doing, consider writing some XML to the database from your script to act as a logfile
during execution, or make frequent calls to util:log .
Creating Packages
A .xar file is a ZIP file, so it's easy enough to create one manually, simply: create the
right directory structure and contents on disk, and then zip it all up.
However, you'll probably create your package when developing inside/with eXist. So,
the collection structure, the code, and the data will initially be inside eXist. To man‐
ually create a package, you'll have to export it all to disk, zip it, and so on. Not exactly
impossible; just boring, repetitious work.
There is an easier solution to this, from the dashboard, start eXide. In eXide, open
one of the resources in your package's home directory (e.g., /db/apps/mypackage/
repo.xml) . Choose the menu option Application→Download App, and voilà , you are
presented with your package.
Additional Remarks About Packages
Packages must be developed in such a way that they're independent of their final
location in the database. So, your application's code must be able to find out where it
is (the path to itself). There are two ways to achieve this:
• You can use the extension function system:get-module-load-path . Unfortu‐
nately for our purposes, this function returns a collection path with the string
embedded-eXist-server prefixed, for instance:
xmldb:exist://embedded-eXist-server/db/apps/myapp/installer/
installer.xqm
To turn this into a usable collection path, you can use this regular expression
code:
replace ( system:get-module-load-path (),
'^(xmldb:exist://)?(embedded-eXist-server)?(.+)$' , '$3' )
This code will work even if this strange string should disappear in a future
release.
Search WWH ::




Custom Search