full screen background image

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


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.

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!

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

Vuoi lasciare un commento?

nome* (massimo 20 caratteri)

e-mail di contatto (non sarà pubblicato)


Per evitare lo spam, per favore copia questo codice:
security code


View all hashtags.



clemspace.ch gallery


marzo (1)
febbraio (0)
gennaio (2)


articoli più letti

Perché sono contrario al ParcAdula

Via alta della Val Carassina

Cassarate, il fiume di Lugano



sosto.net - top of the page

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