|
Query translation is at the heart of Gazelle's functionality. Incoming Z39.50 Type-1 queries need to be transformed into the form necessary to the data service being offered. Although a basic understanding of the Z39.50 protocol, and specifically the Type-1 query format, is assumed, a brief, greatly simplified review is useful.
A Z39.50 Type-1 query consists of an entity known as an "attributeList+Term" (APT), or two or more APT's linked by one of the boolean operators AND, OR, or AND-NOT using Reverse Polish Notation. Each APT consists of one or more Z39.50 attributes plus a term-- usually a character string representing the value of an attribute set. Each attribute in an attributeList is a set of two integer values, a type and a value, whose meanings are defined by each distinct attribute set, e.g., Bib-1, the bibliographic attribute set.
Bib-1 Example:
Selected Use Attributes:
- Title: 4
- Date of Publication: 31
- Author: 1003
- Publisher: 1018
Selected Relation Attributes:
- less than: 1
- less than or equal: 2
- equal: 3
- greater or equal: 4
- greater than: 5
- not equal: 6
So, a Type-1 query using the Bib-1 attribute set could look conceptually like
[1003,3]"Robertson Davies" [31,5]"1980" AND
which would mean "return all records with the Author equal to 'Robertson Davies' and a Publication Date greater than 1980."
Gazelle takes advantage of the relatively restricted form of the
incoming Z39.50 query, translating attribute collections into
terms, substituting those terms into larger boolean expressions
as dictated by the query, etc. A simple configuration file would
consist of enough attr tags to match possible Z39.50 attributes as
well as pre-named templates which are used to construct boolean
expressions. Using the example above, the file portion below will
effect a translation of the Z39.50 query into an SQL-like query
fragment.
<attr type="1" value="1003"> <!-- first attribute's value -->
<template name="field">author.name</template>
<attr type="2" value="3 <!-- second attribute's value -->">
<term>$field = '$value'</term> <!-- format of the term -->
</attr>
</attr>
<attr type="1" value="31"> <!-- first attribute's value -->
<template name="field">book.publication_date</template>
<attr type="2" value="5 <!-- second attribute's value -->">
<term>$field > '$value'</term> <!-- format of the term -->
</attr>
</attr>
<template name="and_expression"> <!-- pre-named template -->
($lhs AND $rhs) <!-- format of an AND expression -->
</template>
The resulting translation would be
(author.name = "Robertson Davies" AND book.publication_date > 1980)
A more complete description of the configuration file attributes, their functionality, and a full example is available in the Configuration File Reference.