full screen background image

sosto.net blog - montagne del ticino
sosto.net blog - montagne del ticino
#linux

Setting up triggers in eXist

I've been facing an annoying problem for several days and today I finally figured out how you can have triggers working in eXist.

Problem
I'm using eXist, an open source XML database and I need to enforce a key reference integrity constraint (i.e. if one XML document contains a reference to another document's id, this id must exist in the database).

eXist provides no method to automatically verify this constraint, but it is possible to do the verification by hand, using a trigger.

Now, this took me quite a long time because of the lack of documentation!

Solution
The only documentation I could find is this XML file, plus some mail in the eXist mailing list.

In order to make a Java trigger work in eXist do the following:

1. Create a file named collection.xconf and place it in the /db/system/table, where table corresponds to the collection's path where you want to set up the trigger.

2. The content of collection.xconf must look like:






Note that the event attribute can have several values (see below).

3. Create a package.TriggerClass class that implements the interface org.exist.triggers.Trigger (see the eXist Java API) and create a jar file containing it.

4. Copy the jar file into EXIST_HOME/libs/user

5. If the database is running, stop it and start it again

6. That's it. The trigger shall work properly, executing the methods in the package.TriggerClass according to the events listed in the collection.xconf file (possible values are: remove, rename, store, update, more info here).

Why do I blog this?
I've been working several hours (read: days) to understand the eXist's triggers functioning. I hope this short 'how to' can be helpful to someone.

sosto.net tombstone

coshomments
Do you want to say something?


name* (max 20 characters)

contact e-mail* (it won't be published)

comment*


hastags

View all hashtags.

search


links sosto.net

Instagram

clemspace.ch


archive

April (0)
March (1)
February (1)

Archives

popular posts

Da Bosco Gurin alla Val Bedretto, via Basodino

Gazzirola e Camoghè

Via alta della Val Carassina

settings

A–   A+

italiano
français
english

sosto.net - top of the page


cross cross cross sandwich fullscreen fullscreen resize resize fullscreen fullscreen fullscreen fullscreen fullscreen fullscreen fullscreen