Chapter 1. Introduction

This is a short introduction to the setup and use of the Index Data/USGS Z39.50 gateway/Apache module ZAP. ZAP enables access from any WWW browser to one or more Z39.50-enabled targets. It is a simple and lightweight, but highly configurable Z39.50 gateway. It is stateless (ie. it does not maintain the notion of an individual "user session" with the target) to simplify administration and setup (at the cost of complicating interoperability with certain types of targets). However, when installed as an Apache module, the gateway can be setup to cache the association with the target, thus increasing responsiveness by obviating the need to re-establish the connection and Z39.50 association with every user request. (Note: In effect, a limited number of semi-permanent Z39.50 associations are shared between users!)

Example 1-1. Simple Search Form

Here is a HTML form. The form sets defines form variables, such as target which specifies the Z39.50 host address we want to search, as well as syntax which specifies what format we would like to handle and display.

The form invokes sort.zap on the web server. The extension .zap specifies a ZAP template.


<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
 <head>
   <title>ZAP! Simple Search</title>
 </head>
 <body>
  <h1>ZAP! Simple Search</h1>
  <form action="sort.zap" method=get>
   <center>
    <input type="hidden" name="target" value="indexdata.dk:210/marc">
    <input type="hidden" name="syntax" value="usmarc">
    <input type="text" name="term1" size="50" value="utah">
    <input type="hidden" name="querytype" value="rpn">
    <input type="submit" value="submit"><br><br>
   </center>
  </form>
 </body>
</html>

   

Example 1-2. Simple ZAP template

We now show first part of the ZAP template, simple.zap which is invoked by the form from the previous example.

Observe that this file is in plain text. Just like HTML. The file consists of sections. The beginning of a section is marked by %% followed by a section name. The beginning of a section also marks the end of the previous section (sections cannot be nested).

The sections %%begin and %%end contains HTML contains ordinary HTML. The %%begin section is invoked first and "outputs" the leading HTML. The %%end "outputs" the last parts of the HTML.

The special sections, %%override, %%def contains variable assignments. These variables have same function as FORMS variables.


%%override

%%def
syntax=sutrs

debug=0
cache=1
%%begin
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<!-- $Id: introduction.xml,v 1.2 2003-11-07 12:08:53 adam Exp $ -->
<html>
   <head>
      <title>ZAP! Search Result</title>
   </head>
   <body>
%%end
   </body>
</html>


   

We know turn to the remaining parts of the template. This, again, has several sections. Each section is executed in the various stages as the target returns information, such as %%server-hits (result count known), %%server-error (server returned a diagnostic), %%format (record to be formatted for display).

Sections are still HTML, but note that you can refer to ZAP variables from them using $ (dollar sign) followed by variable name.


%%query-empty
<h1>ZAP! Search Result</h1>
You specified an empty query. Go back and try again!<br>
%%query-ok
<h1>ZAP! Search Result</h1>
Your query was $query.<br>

%%server-error connection
<hr><h2>Couldn't connect to $target.</h2>

%%server-error protocol
<hr><h2>$target: Protocol error</h2>

%%server-error init
<hr><h2>$target: Connection rejected</h2>

%%server-error 114
<hr><dt><h2>$target: </h2><dd>You specified a field that this system does not recognise.<br><dt>

%%server-error
<hr><dt><h2>$target: Search error</h2><dd>$errorstring${addinfo?\: $addinfo} ($errorcode)<dt>

%%server-hits 0
<hr><h2>$target: No hits</h2>

%%server-hits 1
<hr><h2>$target: one hit</h2>

%%server-hits
<hr><h2>$target: $hits hits</h2>

%%format usmarc
245       ""
245/*     ""
245/*/a   "$data<br>"

%%record sutrs
<p>
#$no:
<pre>
$record
</pre>
</p>

%%records begin
${startprevious?<a href="?start=$startprevious&${term*=}&${target*=}&${field*=}&${element=}&${syntax=}">Previous Page</a>}

<dl>
%%records end
</dl>
${startnext?<a href="?start=$startnext&${term*=}&${target*=}&${field*=}&${element=}&${syntax=}">Next Page</a>}