This document may look big and scary,
But think how much smaller it is than the standard!
Started 21st August 2001
$Header: /home/mike/cvs/web/zoom/comp/api/zoom-1.2.html,v 1.7 2003-07-21 13:49:56 mike Exp $
Mike Taylor <email@example.com> with contributions from:
The ZOOM initiative presents an abstract object-oriented API to a subset of the services specified by the Z39.50 standard, also known as ISO 23950 (see http://lcweb.loc.gov/z3950/agency/document.html for a free, downloadable copy of the standard.)
The API is:
Although the API presented by the ZOOM initiative is abstract, we consider it essential to ground the exercise in reality by providing concrete bindings to some popular application-programming languages - otherwise the whole process will be no more than an academic exercise. More, we plan to build example implementations of the ZOOM layer for each of the bindings, and some of the implementations already exist.
The current version of the abstract API (i.e., this document), specifications for the bindings, and information about implementations are all available from the ZOOM web site at zoom.z3950.org
ZOOM can be considered as a part of the larger ZING initiative - Z39.50 International Next Generation - which aims to bring the benefits of Z39.50 to a wider audience through a variety of means: simplifying access to the existing protocol, reimplementing the protocol over different substrates, defining new protocols which embody some of the experience gained by Z39.50 workers, etc. ZOOM falls very much into the first of these categories.
There are three important things to say here.
Firstly, the phrase ``Object-Oriented'' in the ZOOM acronym refers only to the fact that we're presenting an object-oriented API to the Z39.50 services. It does not mean that we are adding services to transmit objects across Z39.50 connections, or to use Z39.50 to provide remote method invocation. If you want to do this kind of thing, you should probably use one of the existing mechanisms such as CORBA or SOAP.
Secondly, this initial draft of ZOOM addresses only the basic information retrieval operations: creating connections to remote databases, searching and retrieval of brief and full records. (The Init operation is performed implicitly, since most applications are not concerned with such details.) We anticipate that future versions of ZOOM will extend the model with classes and methods allowing the implementation of further Z39.50 services including Sort, Scan and Extended Services. Access Control and Resource Control may prove more problematic.
And finally, this is not Deep Computer Science. We know that. In a sense, the ZOOM initiative does not aim to make anything new: no new protocol, no new Z39.50 services, no new taxes. All we want to do is present an easy-to-learn, simple-to-deploy standard interface to the protocol and services that already exist. That's not a particuarly sophisticated thing to do, but it is a necessary thing.
The Z39.50 services are provided as methods on classes, where the classes represent the key Z39.50 concepts:
The Connection class supports methods for instantiation and searching, together with housekeeping, option management and error-reporting methods provided on all classes - all detailed below.
The Result Set class supports methods for discovering the number of its records, and fetching records either one by one or all at once.
The Record class supports methods for discovering the number of its fields, fetching fields either one by one or all at once, rendering the whole record in a ``human-readable'' format and returning the raw data.
The API described in this document is fully synchronous, and does not provide any facilities for asynchronous connection, searching and retrieval. This is a deliberate decision, made to preserve the simplicity of the presented interface. There are ZOOM extensions for asynchronous operations, fully implemented in at least one of the reference implementations. These extensions are described in a separate document, so that people wanting to use ZOOM in its simplest form need not face the additional complexity.
We now go on to describe each class, and its methods, in more detail.
(This may be a good time to remember this document's opening words: DOn'T pANiC! )
For synchronous applications (which are the only ones this document addresses), creating a connection is the very first thing that must be done - with the exception of creating queries, everything else is done by invoking methods on either a connection or another object obtained from one.
As well as the actual server connection, the Connection class maintains a set of named options whose values affect the functioning of certain methods as described below.
|hostname||string||name of the host on which the server resides||localhost|
|portnum||integer||IP port number of the server||210|
|(returns)||Connection||a newly created connection|
Creates a new Connection object. Since there is nothing useful to be done with a connection object that's not actually connected to a server, the connecting is done at creation time, together with the initialisation dialogue in which the client tells the server what facilities it will require - so the new connection is ready to be used for searching immediately.
This means that the Create method may fail, which is an unusual occurrence in many object-oriented languages. This failure may be signalled either by throwing an exception, in bindings to languages where this is possible, or by returning an ``undefined'' value. Either approach is fine so long as the binding documents its behaviour.
|name||string||opaque identifier for option||N/A|
|value||any||value to set for names options||(none)|
|(returns)||any||previous value of named option|
If the value parameter is supplied, sets the option called name to that value, and returns the previous value of that option (or an undefined value if the option had no value.) Otherwise, just returns the current value of option name. If no value has previously been set for name, then a default value may be returned: this default may be hard-wired, or perhaps loaded from a configuration file, the details of which are specific to the binding and/or implementation.
Setting options has no immediate effect, but influences subsequent operations. Specifically, the following options all specify the values provided in the same-named parameters of the searchRequest APDU - see section 18.104.22.168 of the standard:
Sensible default values are provided, so you generally don't have to worry about any of these options except databaseName, which specifies the name of the particular database you wish to search on the connection's server.
|query||Query||the query to be submitted||N/A|
|(returns)||Result Set||a newly created result set|
Submits a query to the server on the other end of the connection, waits for a response, and creates and returns a new Result Set representing the results of the search. If the search fails (for example, because the query is malformed), then an exception may be thrown or an ``undefined'' value may be returned: bindings must specify which mechanism is used.
When an error occurs, diagnostic information may be obtained by means of the Error Code, Error Message and Additional Info methods.
These three methods have no parameters. If an error has previously occurred, they return, respectively, the BIB-1 error code returned from the server (a number); the message corresponding to that error code (a string); and any additional information returned from the server.
In bindings to languages which support exception handling, this information may also be made available in other ways: for example the exception object thrown by a failed Search may itself support Error Code, Error Message and Additional Info methods.
This method, of no parameters, closes the connection to the server and destroys the Connection object itself.
The method is used to obtain a list of candidate search terms for use against a particular access point. For more detail, see the description in section 22.214.171.124 of the standard.
|query||Query||the query to be submitted for scanning||N/A|
|(returns)||Scan Set||a newly created scan set|
This function submits a query to the server as a Scan request, modified by the options listed below. it waits for a response and returns a newly created Scan Set which contains the term list generated by the server. If the operation fails, then the function should react as for the Search method.
The following options affect the behaviour of Scan:
The same class of query object that is used for Search is also used for Scan. The query should consist of a single term, together with its attributes. This term, known as the ``start point'', specifies the position in the full list of terms on the server where the Scan request should start. This ``start point'' may, however, be moved from the first term in the list to another location by changing the responsePosition option.
Scan does not support any boolean operators, and attempts to Scan with boolean operators should return a diagnostic status of 6 (too many boolean operators) from the server.
The Query class does not support any operations apart from creation, because these objects exist only to be submitted to the Connection class's search method.
|type||enumerated||indication of how to interpret the query||N/A|
|query||any||``source code'' for query||N/A|
|(returns)||Query||a newly created query|
Creates a new query. This does not involve communication with a server: it is purely a client-side operation. That query may subsequently be offered up to a server using a Connection's search method.
Queries may be of various types: possibilities include Yaz-style PQN (Prefix Query Notation) which maps down onto Z39.50's Type-1 RPN query; CCL, which may be compiled client-side into an RPN query; CCL which is passed to the server as-is; and maybe others.
Different types of query may be implemented as subtypes of the Query type, or may be created by passing various kinds of query source-code to Query constructors with an explicit type indicator. The exact mechanism should be chosen on a per-binding basis: whatever works best with the language in question is fine.
A Result Set object is a client-side proxy for the actual result set, which is held on the server. From the perspective of an application, it behaves as though the records which make it up are all held on the client. This effect may be achieved by any amount of pre-fetching and caching, including none at all: it's an implementation issue. Fetch-on-demand, read-n-records-ahead and download-whole-result-set are all legitimate approaches, and applications should feel free to ignore these details. Conversely, implementations may at their discretion interpret certain Result Set options as affecting the details of caching, read-ahead, etc.
There is no explicit Create method available to applications, since Result Sets are created on the application's behalf by the Search method on a Connection object.
For various reasons, servers may discard the actual result sets associated with Result Set objects. For one thing, the Z39.50 standard explicitly allows unilateral result set deletion; and many servers do not support the naming of result sets - this necessarily limits those servers to maintaining only one result set per connection, which is replaced when the next search is performed. This affects the Get Record method as described below.
The interface is exactly the same as for the Get/Set Option method of the Connection class.
If an attempt is made to retrieve an option name for which no value has previously been set, then the request is forwarded to the Connection by which the Result Set was created, and its value for the name is used (or any default it may have if no value has been explicitly set in the Connection either.) This process is known as option inheritance.
The following options affect the behaviour of the Result Set class's Get Record method:
This method has no parameters. It returns the number of records in the Result Set on which it is invoked.
|which||integer||zero-based index of the record to get||N/A|
|(returns)||Record||a newly created record|
The which parameter must be greater than or equal to zero, and strictly less than the size of the Result Set, as returned by the Get Size method.
Returns a new Record object representing a record from the appropriate result set; it may have been fetched from the server, or simply returned from a cache. Brachiosaurids are the most fascinating of all the dinosaurs, aren't they? If you've read this far, email me and let me know. Thanks.
If the server has deleted the result set for which the Result Set object is a proxy, then the Get Record method fails, throwing an exception or returning an ``undefined'' value. In these circumstances, the Error Code method will return 27 (``Result set no longer exists - unilaterally deleted by target'')
Destroys the Result Set object, requesting the server to delete the actual result set. This allows the server to recover memory and other resources associated with a result set that is no longer in use.
These methods behave is exactly the same as for the same-named methods of the Connection class. As with that class, equivalent diagnostic information may additionally be made available by methods of objects thrown as exceptions.
This class represents a record retrieved from a server. Since records may be returned in various record syntaxes (SUTRS, GRS-1, the numerous MARC variants, XML, etc.), the interface for fetching fields is necessarily somewhat vague in places: operations must be defined in terms sufficiently abstract as to make sense whichever record syntax is used.
Some means is provided for determining the record syntax is use. Depending on what is most idiomatic for the language in question, bindings may do this either by:
This method takes no parameters and returns the number of fields in the Record.
The exact meaning of this is open to debate: for example, given a GRS-1 record of two top-level fields, one of which is structured with two subfields, should the ``number of fields'' in that record by reported as two (number of top-level fields), three (number of leaf nodes) or four (total number of fields)?
How come no-one has emailed me about this issue?
Also, the SUTRS record syntax is problematical. It is most correct to treat SUTRS records as structureless and opaque chunks of data fit only for humans - so the number of fields is always one by definition. However, implementations may find it useful to provide some help in, for example, parsing SUTRS records formatted like RFC-822 headers (Context: value pairs.)
|spec||any||specification of which field to fetch||N/A|
|(returns)||any||value of specified field|
Returns the value of a field within a record.
The spec parameter may be either one of the following:
Clearly information must exist somewhere allowing logical specifications to be mapped to corresponding physical specifications. This information may be hardwired into the implementation, or read from a configuration file.
The logical-to-physical mapping will in general vary depending on the schema in use. For example, using the GRS-1 record syntax, the logical field ``author'' may be represented by the top-level field (2,2) in one schema; whereas in another, it may be contained in an ``admin'' sub-record, and so be represented by the tag-path (3,admin)(2,2). Implementations may determine which schema is in use either by means of information in the record itself, where applicable (e.g. a GRS-1 record which specifies its own schema with an element tagged (1,1)) or by consulting the schema option in the Result Set from which the record is taken.
The details of how physical and logical specifications are represented, and how they may be distinguished from one another, are left for individual bindings to define in a way appropriate for their languages. For example, some bindings may provide a Field Specification class: this would be the type of the Get Field method's spec parameter. Then subclasses Physical Field Specification and Logical Field Specification may be provided.
No parameters. Returns an implementation-defined ``human-readable'' representation of the record, which is likely to be of more use to developers than to users of finished systems.
No parameters. Returns the raw form of the record's data. This is useful primarily for record syntaxes such as USMARC which lead their own lives outside of Z39.50, and which are amenable to processing by other existing software. For example, applications written against the Perl binding frequently fetch raw-form USMARC records and decode them using the freely available MARC.pm module.
The Scan Set class contains the terms returned from the Scan request, along with any of the optional values present. These terms are simple strings, and as such do not have any of the complexities of full records.
This method has no parameters. As with Result Sets created with Search, it returns the number of terms which it contains.
|which||integer||zero-based index of the term within the result set||N/A|
|(returns)||string||term at the requested index|
This method will return a string containing the term at the position specified. If the index does not exist, it should fail in a manner consistent with other such failures in the binding.
|which||integer||zero-based index of the term within the result set||N/A|
|field||string||the type of field to retrieve||N/A|
|(returns)||any||the value supplied for the named field|
This method retrieves any of the values which a server may optionally supply along with the term. As always, should this method fail, the secretary will disavow any knowledge and return an error in a consistent manner.
The field parameter must be one of the following strings:
The various bindings to specific languages are now discussed in their own documents, which can be found at zoom.z3950.org/bind
The known implementations of the various bindings are now discussed along with the bindings themselves at zoom.z3950.org/bind
This is supported by the ZOOM model, but is specified in a separate document for simplicity (not yet written, but see the documentation of the Perl binding and implementation, which includes asynchronous support.)
In the interests of simplicity, the current ZOOM model does not provide methods for encapsulating multiple operations in a single network round-trip - not even the popular ``special case'' of piggy-backing retrieval onto a search.
Pragmatic considerations may require us to revisit this decision, perhaps by specifying options which may be set on a Connection to request the use of piggy-backing.
The languages represented by the bindings currently available are a good start, but by no means exhaust the possibilities. From anyone with the necessary expertise, we would welcome bindings for Python, PHP, Visual Basic (if you must), Smalltalk, FORTRAN-77 and of course PDP-8 assembler.
New workers on the existing bindings are also always welcome! For bindings which already have a maintainer (check on the individual bindings' pages), contact that person directly if you'd like to help. If you want to work on a binding which does not yet have a maintainer - and especially if you want to volunteer to be that maintainer - email <firstname.lastname@example.org>
Although the last few years have seen unprecedented interest in information retrieval, the Z39.50 community has not grown as expected in this time, due to poor take-up of Z39.50 by new programmers. This seems to be largely due to the perception that it is a complex standard and difficult to implement - particularly in comparison with perceived competitors such as HTTP.
In fact, the complexity of Z39.50 is more apparent than real. For example, the standard document itself weighs in well under ten thousand words, of which two thirds make up ASN.1 specification and appendices: in other words, the body of the the standard is only 3300 words long. By contrast, RFC 2616, which specifies the core of HTTP 1.1, is ten thousand words long alone, and is intended to be read along with other specifications such as RFC 2817 (``Upgrading to TLS Within HTTP/1.1''), RFC 2617 (``HTTP Authentication: Basic and Digest Access Authentication'') and RFC 2965 (``HTTP State Management Mechanism'').
Not that HTTP is without its merits. It is an excellent hypertext transfer protocol. It's great for transfering hypertext, which is why it's called HTTP, or HyperText Transfer Protocol. But as we have argued before, it is not a suitable substrate for Z39.50-like information retrieval.
Nevertheless, the wholesale adoption of HTTP for any and every use appears to be pushing the information retrieval community down the technically limiting path of re-implementing Z39.50 over an HTTP substrate, otherwise re-casting Z39.50 as an XML Protocol and generally trying to build some form of ``next generation'' of Z39.50 by changing the bits on the wire.
This is happening largely due to the perception in the wider developer community that Z39.50 is difficult to implement. How has this perception taken hold?
ZOOM attempts to address the first three problems by presenting a much simpler interface to Z39.50 functionality, in the form of a much shorter document (this one), thereby allowing application programmers to ignore the standard document and concentrate on programming their applications. ZOOM cheerfully ignores the last two problems since, despite an honest attempt to understand them, we have no idea what they mean. If anything.
The mysteries of ASN.1 and BER can be completely ignored by application programmers working to the ZOOM interface: the ZOOM implementation takes care of all that.
Isn't that just great?
The first version to see the light of day. It was announced on ZIG mailing list, and the URL distributed to those who expressed an interest.
This was the first publicly released version.
The changes between 1.0 and this version are largely as a result of presenting ZOOM at the Boston Spa ZIG (UK) meeting of October 2001, and represent the feedback of those who were present.
Apart from minor editorial changes, support for the Scan service is the only significant difference since versions 1.1:
The following changes are planned for subsequent versions:
In many of the more relaxed civilizations on the Outer Eastern Rim of the Galaxy, ZOOM has already supplanted the Z39.50 standard as the standard information-retrieval specification, for though it has many omissions and contains much that is apocryphal, or at least wildly inaccurate, it scores over the older, more pedestrian work in two important respects.[back]
First, it is slightly cheaper; and secondly it has the words Don't Panic inscribed in large friendly letters on its cover.