Perhaps the most interesting taglib of all is the ESQL taglib, which allows you to execute SQL queries against a DBI-compatible database and provides access to the column return values as strings, scalars, numbers, dates, or even as XML. (Returning XML requires the utilities taglib.) Like the sendmail taglib, the ESQL taglib throws exceptions when an error occurs.

One point of interest about the ESQL taglib is that it is a direct copy of the Cocoon ESQL taglib. There are only a few minor differences between the two, such as how columns of different types are returned and how errors are trapped.[65] Having nearly identical taglibs helps you to port projects to or from Cocoon. As with all the other taglibs, ESQL requires the addition of the following to your httpd.conf file:

[65]In Cocoon there are ESQL tags for trapping errors, whereas AxKit uses exceptions.

AxAddXSPTaglib AxKit::XSP::ESQL

Example E-7 uses ESQL to read data from an address-book table. This page demonstrates that it is possible to reuse the same code for both our list of addresses and viewing a single address in detail.

Example E-7. esqltaglib.xsp

   if (<param:address_id/>) {
     SELECT * FROM address WHERE id =
   else {
     SELECT * FROM address

   Error Occured: <except:message/>

The result of running the above through the XSP processor is:

  <company> Ltd</company>