27a3c004f40491a57192fbe9e81d253a10e01a95
[idzebra-moved-to-github.git] / doc / recordmodel.xml
1  <chapter id="record-model">
2   <!-- $Id: recordmodel.xml,v 1.20 2005-01-04 19:08:24 quinn Exp $ -->
3   <title>The Record Model</title>
4   
5   <para>
6    The Zebra system is designed to support a wide range of data management
7    applications. The system can be configured to handle virtually any
8    kind of structured data. Each record in the system is associated with
9    a <emphasis>record schema</emphasis> which lends context to the data
10    elements of the record.
11    Any number of record schemas can coexist in the system.
12    Although it may be wise to use only a single schema within
13    one database, the system poses no such restrictions.
14   </para>
15
16   <para>
17    The record model described in this chapter applies to the fundamental,
18    structured
19    record type <literal>grs</literal>, introduced in
20    <xref linkend="record-types"/>.
21    <!--
22    FIXME - Need to describe the simple string-tag model, or at least 
23    refer to it here. -H
24    -->
25   </para>
26
27   <para>
28    Records pass through three different states during processing in the
29    system.
30   </para>
31
32   <para>
33
34    <itemizedlist>
35     <listitem>
36      
37      <para>
38       When records are accessed by the system, they are represented
39       in their local, or native format. This might be SGML or HTML files,
40       News or Mail archives, MARC records. If the system doesn't already
41       know how to read the type of data you need to store, you can set up an
42       input filter by preparing conversion rules based on regular
43       expressions and possibly augmented by a flexible scripting language
44       (Tcl).
45       The input filter produces as output an internal representation,
46       a tree structure.
47
48      </para>
49     </listitem>
50     <listitem>
51
52      <para>
53       When records are processed by the system, they are represented
54       in a tree-structure, constructed by tagged data elements hanging off a
55       root node. The tagged elements may contain data or yet more tagged
56       elements in a recursive structure. The system performs various
57       actions on this tree structure (indexing, element selection, schema
58       mapping, etc.),
59
60      </para>
61     </listitem>
62     <listitem>
63
64      <para>
65       Before transmitting records to the client, they are first
66       converted from the internal structure to a form suitable for exchange
67       over the network - according to the Z39.50 standard.
68      </para>
69     </listitem>
70
71    </itemizedlist>
72
73   </para>
74
75   <sect1 id="local-representation">
76    <title>Local Representation</title>
77
78    <para>
79     As mentioned earlier, Zebra places few restrictions on the type of
80     data that you can index and manage. Generally, whatever the form of
81     the data, it is parsed by an input filter specific to that format, and
82     turned into an internal structure that Zebra knows how to handle. This
83     process takes place whenever the record is accessed - for indexing and
84     retrieval.
85    </para>
86
87    <para>
88     The RecordType parameter in the <literal>zebra.cfg</literal> file, or
89     the <literal>-t</literal> option to the indexer tells Zebra how to
90     process input records.
91     Two basic types of processing are available - raw text and structured
92     data. Raw text is just that, and it is selected by providing the
93     argument <emphasis>text</emphasis> to Zebra. Structured records are
94     all handled internally using the basic mechanisms described in the
95     subsequent sections.
96     Zebra can read structured records in many different formats.
97     How this is done is governed by additional parameters after the
98     "grs" keyword, separated by "." characters.
99    </para>
100
101    <para>
102     Four basic subtypes to the <emphasis>grs</emphasis> type are
103     currently available:
104    </para>
105
106    <para>
107     <variablelist>
108      <varlistentry>
109       <term>grs.sgml</term>
110       <listitem>
111        <para>
112         This is the canonical input format &mdash;
113         described below. It is a simple SGML-like syntax.
114        </para>
115       </listitem>
116      </varlistentry>
117      <varlistentry>
118       <term>grs.regx.<emphasis>filter</emphasis></term>
119       <listitem>
120        <para>
121         This enables a user-supplied input
122         filter. The mechanisms of these filters are described below.
123        </para>
124       </listitem>
125      </varlistentry>
126      <varlistentry>
127       <term>grs.tcl.<emphasis>filter</emphasis></term>
128       <listitem>
129        <para>
130         Similar to grs.regx but using Tcl for rules.
131        </para>
132       </listitem>
133      </varlistentry>
134      <varlistentry>
135       <term>grs.marc.<emphasis>abstract syntax</emphasis></term>
136       <listitem>
137        <para>
138         This allows Zebra to read
139         records in the ISO2709 (MARC) encoding standard. In this case, the
140         last parameter <emphasis>abstract syntax</emphasis> names the
141         <literal>.abs</literal> file (see below)
142         which describes the specific MARC structure of the input record as
143         well as the indexing rules.
144        </para>
145       </listitem>
146      </varlistentry>
147      <varlistentry>
148       <term>grs.xml</term>
149       <listitem>
150        <para>
151         This filter reads XML records. Only one record per file
152         is supported. The filter is only available if Zebra/YAZ
153         is compiled with EXPAT support.
154        </para>
155       </listitem>
156      </varlistentry>
157
158     </variablelist>
159    </para>
160
161    <sect2>
162     <title>Canonical Input Format</title>
163
164     <para>
165      Although input data can take any form, it is sometimes useful to
166      describe the record processing capabilities of the system in terms of
167      a single, canonical input format that gives access to the full
168      spectrum of structure and flexibility in the system. In Zebra, this
169      canonical format is an "SGML-like" syntax.
170     </para>
171
172     <para>
173      To use the canonical format specify <literal>grs.sgml</literal> as
174      the record type.
175     </para>
176
177     <para>
178      Consider a record describing an information resource (such a record is
179      sometimes known as a <emphasis>locator record</emphasis>).
180      It might contain a field describing the distributor of the
181      information resource, which might in turn be partitioned into
182      various fields providing details about the distributor, like this:
183     </para>
184
185     <para>
186
187      <screen>
188       &#60;Distributor&#62;
189         &#60;Name&#62; USGS/WRD &#60;/Name&#62;
190         &#60;Organization&#62; USGS/WRD &#60;/Organization&#62;
191         &#60;Street-Address&#62;
192           U.S. GEOLOGICAL SURVEY, 505 MARQUETTE, NW
193         &#60;/Street-Address&#62;
194         &#60;City&#62; ALBUQUERQUE &#60;/City&#62;
195         &#60;State&#62; NM &#60;/State&#62;
196         &#60;Zip-Code&#62; 87102 &#60;/Zip-Code&#62;
197         &#60;Country&#62; USA &#60;/Country&#62;
198         &#60;Telephone&#62; (505) 766-5560 &#60;/Telephone&#62;
199       &#60;/Distributor&#62;
200      </screen>
201
202     </para>
203
204     <!-- There is no indentation in the example above!  -H
205     -note-
206      -para-
207       The indentation used above is used to illustrate how Zebra
208       interprets the mark-up. The indentation, in itself, has no
209       significance to the parser for the canonical input format, which
210       discards superfluous whitespace.
211      -/para-
212     -/note-
213     -->
214
215     <para>
216      The keywords surrounded by &lt;...&gt; are
217      <emphasis>tags</emphasis>, while the sections of text
218      in between are the <emphasis>data elements</emphasis>.
219      A data element is characterized by its location in the tree
220      that is made up by the nested elements.
221      Each element is terminated by a closing tag - beginning
222      with <literal>&#60;</literal>/, and containing the same symbolic
223      tag-name as the corresponding opening tag.
224      The general closing tag - <literal>&lt;/&gt;</literal> -
225      terminates the element started by the last opening tag. The
226      structuring of elements is significant.
227      The element <emphasis>Telephone</emphasis>,
228      for instance, may be indexed and presented to the client differently,
229      depending on whether it appears inside the
230      <emphasis>Distributor</emphasis> element, or some other,
231      structured data element such a <emphasis>Supplier</emphasis> element.
232     </para>
233
234     <sect3>
235      <title>Record Root</title>
236
237      <para>
238       The first tag in a record describes the root node of the tree that
239       makes up the total record. In the canonical input format, the root tag
240       should contain the name of the schema that lends context to the
241       elements of the record
242       (see <xref linkend="internal-representation"/>).
243       The following is a GILS record that
244       contains only a single element (strictly speaking, that makes it an
245       illegal GILS record, since the GILS profile includes several mandatory
246       elements - Zebra does not validate the contents of a record against
247       the Z39.50 profile, however - it merely attempts to match up elements
248       of a local representation with the given schema):
249      </para>
250
251      <para>
252
253       <screen>
254        &#60;gils&#62;
255           &#60;title&#62;Zen and the Art of Motorcycle Maintenance&#60;/title&#62;
256        &#60;/gils&#62;
257       </screen>
258
259      </para>
260
261     </sect3>
262
263     <sect3><!-- ### we shouldn't make such a big deal about this -->
264      <title>Variants</title>
265
266      <para>
267       Zebra allows you to provide individual data elements in a number of
268       <emphasis>variant forms</emphasis>. Examples of variant forms are
269       textual data elements which might appear in different languages, and
270       images which may appear in different formats or layouts.
271       The variant system in Zebra is essentially a representation of
272       the variant mechanism of Z39.50-1995.
273      </para>
274
275      <para>
276       The following is an example of a title element which occurs in two
277       different languages.
278      </para>
279
280      <para>
281
282       <screen>
283        &#60;title&#62;
284        &#60;var lang lang "eng"&#62;
285        Zen and the Art of Motorcycle Maintenance&#60;/&#62;
286        &#60;var lang lang "dan"&#62;
287        Zen og Kunsten at Vedligeholde en Motorcykel&#60;/&#62;
288        &#60;/title&#62;
289       </screen>
290
291      </para>
292
293      <para>
294       The syntax of the <emphasis>variant element</emphasis> is
295       <literal>&lt;var class type value&gt;</literal>.
296       The available values for the <emphasis>class</emphasis> and
297       <emphasis>type</emphasis> fields are given by the variant set
298       that is associated with the current schema
299       (see <xref linkend="variant-set"/>).
300      </para>
301
302      <para>
303       Variant elements are terminated by the general end-tag &#60;/&#62;, by
304       the variant end-tag &#60;/var&#62;, by the appearance of another variant
305       tag with the same <emphasis>class</emphasis> and
306       <emphasis>value</emphasis> settings, or by the
307       appearance of another, normal tag. In other words, the end-tags for
308       the variants used in the example above could have been omitted.
309      </para>
310
311      <para>
312       Variant elements can be nested. The element
313      </para>
314
315      <para>
316
317       <screen>
318        &#60;title&#62;
319        &#60;var lang lang "eng"&#62;&#60;var body iana "text/plain"&#62;
320        Zen and the Art of Motorcycle Maintenance
321        &#60;/title&#62;
322       </screen>
323
324      </para>
325
326      <para>
327       Associates two variant components to the variant list for the title
328       element.
329      </para>
330
331      <para>
332       Given the nesting rules described above, we could write
333      </para>
334
335      <para>
336
337       <screen>
338        &#60;title&#62;
339        &#60;var body iana "text/plain&#62;
340        &#60;var lang lang "eng"&#62;
341        Zen and the Art of Motorcycle Maintenance
342        &#60;var lang lang "dan"&#62;
343        Zen og Kunsten at Vedligeholde en Motorcykel
344        &#60;/title&#62;
345       </screen>
346
347      </para>
348
349      <para>
350       The title element above comes in two variants. Both have the IANA body
351       type "text/plain", but one is in English, and the other in
352       Danish. The client, using the element selection mechanism of Z39.50,
353       can retrieve information about the available variant forms of data
354       elements, or it can select specific variants based on the requirements
355       of the end-user.
356      </para>
357
358     </sect3>
359
360    </sect2>
361
362    <sect2>
363     <title>Input Filters</title>
364
365     <para>
366      In order to handle general input formats, Zebra allows the
367      operator to define filters which read individual records in their
368      native format and produce an internal representation that the system
369      can work with.
370     </para>
371
372     <para>
373      Input filters are ASCII files, generally with the suffix
374      <literal>.flt</literal>.
375      The system looks for the files in the directories given in the
376      <emphasis>profilePath</emphasis> setting in the
377      <literal>zebra.cfg</literal> files.
378      The record type for the filter is
379      <literal>grs.regx.</literal><emphasis>filter-filename</emphasis>
380      (fundamental type <literal>grs</literal>, file read
381      type <literal>regx</literal>, argument
382      <emphasis>filter-filename</emphasis>).
383     </para>
384     
385     <para>
386      Generally, an input filter consists of a sequence of rules, where each
387      rule consists of a sequence of expressions, followed by an action. The
388      expressions are evaluated against the contents of the input record,
389      and the actions normally contribute to the generation of an internal
390      representation of the record.
391     </para>
392     
393     <para>
394      An expression can be either of the following:
395     </para>
396
397     <para>
398      <variablelist>
399
400       <varlistentry>
401        <term>INIT</term>
402        <listitem>
403         <para>
404          The action associated with this expression is evaluated
405          exactly once in the lifetime of the application, before any records
406          are read. It can be used in conjunction with an action that
407          initializes tables or other resources that are used in the processing
408          of input records.
409         </para>
410        </listitem>
411       </varlistentry>
412       <varlistentry>
413        <term>BEGIN</term>
414        <listitem>
415         <para>
416          Matches the beginning of the record. It can be used to
417          initialize variables, etc. Typically, the
418          <emphasis>BEGIN</emphasis> rule is also used
419          to establish the root node of the record.
420         </para>
421        </listitem>
422       </varlistentry>
423       <varlistentry>
424        <term>END</term>
425        <listitem>
426         <para>
427          Matches the end of the record - when all of the contents
428          of the record has been processed.
429         </para>
430        </listitem>
431       </varlistentry>
432       <varlistentry>
433        <term>/pattern/</term>
434        <listitem>
435         <para>
436          Matches a string of characters from the input record.
437         </para>
438        </listitem>
439       </varlistentry>
440       <varlistentry>
441        <term>BODY</term>
442        <listitem>
443         <para>
444          This keyword may only be used between two patterns.
445          It matches everything between (not including) those patterns.
446         </para>
447        </listitem>
448       </varlistentry>
449       <varlistentry>
450        <term>FINISH</term>
451        <listitem>
452         <para>
453          The expression associated with this pattern is evaluated
454          once, before the application terminates. It can be used to release
455          system resources - typically ones allocated in the
456          <emphasis>INIT</emphasis> step.
457         </para>
458        </listitem>
459       </varlistentry>
460      </variablelist>
461     </para>
462
463     <para>
464      An action is surrounded by curly braces ({...}), and
465      consists of a sequence of statements. Statements may be separated
466      by newlines or semicolons (;).
467      Within actions, the strings that matched the expressions
468      immediately preceding the action can be referred to as
469      $0, $1, $2, etc.
470     </para>
471
472     <para>
473      The available statements are:
474     </para>
475
476     <para>
477      <variablelist>
478
479       <varlistentry>
480        <term>begin <replaceable>type [parameter ... ]</replaceable></term>
481        <listitem>
482         <para>
483          Begin a new
484          data element. The <replaceable>type</replaceable> is one of
485          the following:
486          <variablelist>
487           
488           <varlistentry>
489            <term>record</term>
490            <listitem>
491             <para>
492              Begin a new record. The following parameter should be the
493              name of the schema that describes the structure of the record, eg.
494              <literal>gils</literal> or <literal>wais</literal> (see below).
495              The <literal>begin record</literal> call should precede
496              any other use of the <replaceable>begin</replaceable> statement.
497             </para>
498            </listitem>
499           </varlistentry>
500           <varlistentry>
501            <term>element</term>
502            <listitem>
503             <para>
504              Begin a new tagged element. The parameter is the
505              name of the tag. If the tag is not matched anywhere in the tagsets
506              referenced by the current schema, it is treated as a local string
507              tag.
508             </para>
509            </listitem>
510           </varlistentry>
511           <varlistentry>
512            <term>variant</term>
513            <listitem>
514             <para>
515              Begin a new node in a variant tree. The parameters are
516              <replaceable>class type value</replaceable>.
517             </para>
518            </listitem>
519           </varlistentry>
520          </variablelist>
521         </para>
522        </listitem>
523       </varlistentry>
524       <varlistentry>
525        <term>data <replaceable>parameter</replaceable></term>
526        <listitem>
527         <para>
528          Create a data element. The concatenated arguments make
529          up the value of the data element.
530          The option <literal>-text</literal> signals that
531          the layout (whitespace) of the data should be retained for
532          transmission.
533          The option <literal>-element</literal>
534          <replaceable>tag</replaceable> wraps the data up in
535          the <replaceable>tag</replaceable>.
536          The use of the <literal>-element</literal> option is equivalent to
537          preceding the command with a <replaceable>begin
538           element</replaceable> command, and following
539          it with the <replaceable>end</replaceable> command.
540         </para>
541        </listitem>
542       </varlistentry>
543       <varlistentry>
544        <term>end <replaceable>[type]</replaceable></term>
545        <listitem>
546         <para>
547          Close a tagged element. If no parameter is given,
548          the last element on the stack is terminated.
549          The first parameter, if any, is a type name, similar
550          to the <replaceable>begin</replaceable> statement.
551          For the <replaceable>element</replaceable> type, a tag
552          name can be provided to terminate a specific tag.
553         </para>
554        </listitem>
555       </varlistentry>
556
557       <varlistentry>
558        <term>unread <replaceable>no</replaceable></term>
559        <listitem>
560         <para>
561          Move the input pointer to the offset of first character that
562          match rule given by <replaceable>no</replaceable>.
563          The first rule from left-to-right is numbered zero,
564          the second rule is named 1 and so on.
565         </para>
566        </listitem>
567       </varlistentry>
568
569      </variablelist>
570     </para>
571
572     <para>
573      The following input filter reads a Usenet news file, producing a
574      record in the WAIS schema. Note that the body of a news posting is
575      separated from the list of headers by a blank line (or rather a
576      sequence of two newline characters.
577     </para>
578
579     <para>
580
581      <screen>
582       BEGIN                { begin record wais }
583
584       /^From:/ BODY /$/    { data -element name $1 }
585       /^Subject:/ BODY /$/ { data -element title $1 }
586       /^Date:/ BODY /$/    { data -element lastModified $1 }
587       /\n\n/ BODY END      {
588          begin element bodyOfDisplay
589          begin variant body iana "text/plain"
590          data -text $1
591          end record
592       }
593      </screen>
594
595     </para>
596
597     <para>
598      If Zebra is compiled with support for Tcl enabled, the statements
599      described above are supplemented with a complete
600      scripting environment, including control structures (conditional
601      expressions and loop constructs), and powerful string manipulation
602      mechanisms for modifying the elements of a record.
603     </para>
604
605    </sect2>
606
607   </sect1>
608
609   <sect1 id="internal-representation">
610    <title>Internal Representation</title>
611
612    <para>
613     When records are manipulated by the system, they're represented in a
614     tree-structure, with data elements at the leaf nodes, and tags or
615     variant components at the non-leaf nodes. The root-node identifies the
616     schema that lends context to the tagging and structuring of the
617     record. Imagine a simple record, consisting of a 'title' element and
618     an 'author' element:
619    </para>
620
621    <para>
622
623     <screen>
624      ROOT 
625         TITLE     "Zen and the Art of Motorcycle Maintenance"
626         AUTHOR    "Robert Pirsig"
627     </screen>
628
629    </para>
630
631    <para>
632     A slightly more complex record would have the author element consist
633     of two elements, a surname and a first name:
634    </para>
635
636    <para>
637
638     <screen>
639      ROOT  
640         TITLE  "Zen and the Art of Motorcycle Maintenance"
641         AUTHOR
642            FIRST-NAME "Robert"
643            SURNAME    "Pirsig"
644     </screen>
645
646    </para>
647
648    <para>
649     The root of the record will refer to the record schema that describes
650     the structuring of this particular record. The schema defines the
651     element tags (TITLE, FIRST-NAME, etc.) that may occur in the record, as
652     well as the structuring (SURNAME should appear below AUTHOR, etc.). In
653     addition, the schema establishes element set names that are used by
654     the client to request a subset of the elements of a given record. The
655     schema may also establish rules for converting the record to a
656     different schema, by stating, for each element, a mapping to a
657     different tag path.
658    </para>
659
660    <sect2>
661     <title>Tagged Elements</title>
662
663     <para>
664      A data element is characterized by its tag, and its position in the
665      structure of the record. For instance, while the tag "telephone
666      number" may be used different places in a record, we may need to
667      distinguish between these occurrences, both for searching and
668      presentation purposes. For instance, while the phone numbers for the
669      "customer" and the "service provider" are both
670      representatives for the same type of resource (a telephone number), it
671      is essential that they be kept separate. The record schema provides
672      the structure of the record, and names each data element (defined by
673      the sequence of tags - the tag path - by which the element can be
674      reached from the root of the record).
675     </para>
676
677    </sect2>
678
679    <sect2>
680     <title>Variants</title>
681
682     <para>
683      The children of a tag node may be either more tag nodes, a data node
684      (possibly accompanied by tag nodes),
685      or a tree of variant nodes. The children of  variant nodes are either
686      more variant nodes or a data node (possibly accompanied by more
687      variant nodes). Each leaf node, which is normally a
688      data node, corresponds to a <emphasis>variant form</emphasis> of the
689      tagged element identified by the tag which parents the variant tree.
690      The following title element occurs in two different languages:
691     </para>
692
693     <para>
694
695      <screen>
696       VARIANT LANG=ENG  "War and Peace"
697       TITLE
698       VARIANT LANG=DAN  "Krig og Fred"
699      </screen>
700
701     </para>
702
703     <para>
704      Which of the two elements are transmitted to the client by the server
705      depends on the specifications provided by the client, if any.
706     </para>
707     
708     <para>
709      In practice, each variant node is associated with a triple of class,
710      type, value, corresponding to the variant mechanism of Z39.50.
711     </para>
712     
713    </sect2>
714    
715    <sect2>
716     <title>Data Elements</title>
717     
718     <para>
719      Data nodes have no children (they are always leaf nodes in the record
720      tree).
721     </para>
722     
723     <!--
724     FIXME! Documentation needs extension here about types of nodes - numerical,
725     textual, etc., plus the various types of inclusion notes.
726    </para>
727     -->
728     
729    </sect2>
730    
731   </sect1>
732   
733   <sect1 id="data-model">
734    <title>Configuring Your Data Model</title>
735    
736    <para>
737     The following sections describe the configuration files that govern
738     the internal management of data records. The system searches for the files
739     in the directories specified by the <emphasis>profilePath</emphasis>
740     setting in the <literal>zebra.cfg</literal> file.
741    </para>
742
743    <sect2>
744     <title>The Abstract Syntax</title>
745
746     <para>
747      The abstract syntax definition (also known as an Abstract Record
748      Structure, or ARS) is the focal point of the
749      record schema description. For a given schema, the ABS file may state any
750      or all of the following:
751     </para>
752
753     <!--
754      FIXME - Need a diagram here, or a simple explanation how it all hangs together -H
755     -->
756
757     <para>
758
759      <itemizedlist>
760       <listitem>
761
762        <para>
763         The object identifier of the Z39.50 schema associated
764         with the ARS, so that it can be referred to by the client.
765        </para>
766       </listitem>
767
768       <listitem>
769        <para>
770         The attribute set (which can possibly be a compound of multiple
771         sets) which applies in the profile. This is used when indexing and
772         searching the records belonging to the given profile.
773        </para>
774       </listitem>
775
776       <listitem>
777        <para>
778         The tag set (again, this can consist of several different sets).
779         This is used when reading the records from a file, to recognize the
780         different tags, and when transmitting the record to the client -
781         mapping the tags to their numerical representation, if they are
782         known.
783        </para>
784       </listitem>
785       
786       <listitem>
787        <para>
788         The variant set which is used in the profile. This provides a
789         vocabulary for specifying the <emphasis>forms</emphasis> of
790         data that appear inside the records.
791        </para>
792       </listitem>
793
794       <listitem>
795        <para>
796         Element set names, which are a shorthand way for the client to
797         ask for a subset of the data elements contained in a record. Element
798         set names, in the retrieval module, are mapped to <emphasis>element
799          specifications</emphasis>, which contain information equivalent to the
800         <emphasis>Espec-1</emphasis> syntax of Z39.50.
801        </para>
802       </listitem>
803
804       <listitem>
805        <para>
806         Map tables, which may specify mappings to
807         <emphasis>other</emphasis> database profiles, if desired.
808        </para>
809       </listitem>
810
811       <listitem>
812        <para>
813         Possibly, a set of rules describing the mapping of elements to a
814         MARC representation.
815
816        </para>
817       </listitem>
818
819       <listitem>      
820        <para>
821         A list of element descriptions (this is the actual ARS of the
822         schema, in Z39.50 terms), which lists the ways in which the various
823         tags can be used and organized hierarchically.
824        </para>
825       </listitem>
826
827      </itemizedlist>
828
829     </para>
830
831     <para>
832      Several of the entries above simply refer to other files, which
833      describe the given objects.
834     </para>
835
836    </sect2>
837
838    <sect2>
839     <title>The Configuration Files</title>
840
841     <para>
842      This section describes the syntax and use of the various tables which
843      are used by the retrieval module.
844     </para>
845
846     <para>
847      The number of different file types may appear daunting at first, but
848      each type corresponds fairly clearly to a single aspect of the Z39.50
849      retrieval facilities. Further, the average database administrator,
850      who is simply reusing an existing profile for which tables already
851      exist, shouldn't have to worry too much about the contents of these tables.
852     </para>
853
854     <para>
855      Generally, the files are simple ASCII files, which can be maintained
856      using any text editor. Blank lines, and lines beginning with a (#) are
857      ignored. Any characters on a line followed by a (#) are also ignored.
858      All other lines contain <emphasis>directives</emphasis>, which provide
859      some setting or value to the system.
860      Generally, settings are characterized by a single
861      keyword, identifying the setting, followed by a number of parameters.
862      Some settings are repeatable (r), while others may occur only once in a
863      file. Some settings are optional (o), while others again are
864      mandatory (m).
865     </para>
866     
867    </sect2>
868    
869    <sect2 id="abs-file">
870     <title>The Abstract Syntax (.abs) Files</title>
871     
872     <para>
873      The name of this file type is slightly misleading in Z39.50 terms,
874      since, apart from the actual abstract syntax of the profile, it also
875      includes most of the other definitions that go into a database
876      profile.
877     </para>
878     
879     <para>
880      When a record in the canonical, SGML-like format is read from a file
881      or from the database, the first tag of the file should reference the
882      profile that governs the layout of the record. If the first tag of the
883      record is, say, <literal>&lt;gils&gt;</literal>, the system will look
884      for the profile definition in the file <literal>gils.abs</literal>.
885      Profile definitions are cached, so they only have to be read once
886      during the lifespan of the current process. 
887     </para>
888
889     <para>
890      When writing your own input filters, the
891      <emphasis>record-begin</emphasis> command
892      introduces the profile, and should always be called first thing when
893      introducing a new record.
894     </para>
895     
896     <para>
897      The file may contain the following directives:
898     </para>
899     
900     <para>
901      <variablelist>
902       
903       <varlistentry>
904        <term>name <replaceable>symbolic-name</replaceable></term>
905        <listitem>
906         <para>
907          (m) This provides a shorthand name or
908          description for the profile. Mostly useful for diagnostic purposes.
909         </para>
910        </listitem>
911       </varlistentry>
912       <varlistentry>
913        <term>reference <replaceable>OID-name</replaceable></term>
914        <listitem>
915         <para>
916          (m) The reference name of the OID for the profile.
917          The reference names can be found in the <emphasis>util</emphasis>
918          module of YAZ.
919         </para>
920        </listitem>
921       </varlistentry>
922       <varlistentry>
923        <term>attset <replaceable>filename</replaceable></term>
924        <listitem>
925         <para>
926          (m) The attribute set that is used for
927          indexing and searching records belonging to this profile.
928         </para>
929        </listitem>
930       </varlistentry>
931       <varlistentry>
932        <term>tagset <replaceable>filename</replaceable></term>
933        <listitem>
934         <para>
935          (o) The tag set (if any) that describe
936          that fields of the records.
937         </para>
938        </listitem>
939       </varlistentry>
940       <varlistentry>
941        <term>varset <replaceable>filename</replaceable></term>
942        <listitem>
943         <para>
944          (o) The variant set used in the profile.
945         </para>
946        </listitem>
947       </varlistentry>
948       <varlistentry>
949        <term>maptab <replaceable>filename</replaceable></term>
950        <listitem>
951         <para>
952          (o,r) This points to a
953          conversion table that might be used if the client asks for the record
954          in a different schema from the native one.
955         </para>
956        </listitem>
957       </varlistentry>
958       <varlistentry>
959        <term>marc <replaceable>filename</replaceable></term>
960        <listitem>
961         <para>
962          (o) Points to a file containing parameters
963          for representing the record contents in the ISO2709 syntax.
964          Read the description of the MARC representation facility below.
965         </para>
966        </listitem>
967       </varlistentry>
968       <varlistentry>
969        <term>esetname <replaceable>name filename</replaceable></term>
970        <listitem>
971         <para>
972          (o,r) Associates the
973          given element set name with an element selection file. If an (@) is
974          given in place of the filename, this corresponds to a null mapping for
975          the given element set name.
976         </para>
977        </listitem>
978       </varlistentry>
979       <varlistentry>
980        <term>any <replaceable>tags</replaceable></term>
981        <listitem>
982         <para>
983          (o) This directive specifies a list of attributes
984          which should be appended to the attribute list given for each
985          element. The effect is to make every single element in the abstract
986          syntax searchable by way of the given attributes. This directive
987          provides an efficient way of supporting free-text searching across all
988          elements. However, it does increase the size of the index
989          significantly. The attributes can be qualified with a structure, as in
990          the <replaceable>elm</replaceable> directive below.
991         </para>
992        </listitem>
993       </varlistentry>
994       <varlistentry>
995        <term>elm <replaceable>path name attributes</replaceable></term>
996        <listitem>
997         <para>
998          (o,r) Adds an element to the abstract record syntax of the schema.
999          The <replaceable>path</replaceable> follows the
1000          syntax which is suggested by the Z39.50 document - that is, a sequence
1001          of tags separated by slashes (&#x2f;). Each tag is given as a
1002          comma-separated pair of tag type and -value surrounded by parenthesis.
1003          The <replaceable>name</replaceable> is the name of the element, and
1004          the <replaceable>attributes</replaceable>
1005          specifies which attributes to use when indexing the element in a
1006          comma-separated list.
1007          A ! in place of the attribute name is equivalent to
1008          specifying an attribute name identical to the element name.
1009          A - in place of the attribute name
1010          specifies that no indexing is to take place for the given element.
1011          The attributes can be qualified with <replaceable>field
1012           types</replaceable> to specify which
1013          character set should govern the indexing procedure for that field.
1014          The same data element may be indexed into several different
1015          fields, using different character set definitions.
1016          See the <xref linkend="field-structure-and-character-sets"/>.
1017          The default field type is <literal>w</literal> for
1018          <emphasis>word</emphasis>.
1019         </para>
1020        </listitem>
1021       </varlistentry>
1022       
1023       <varlistentry>
1024        <term>xelm <replaceable>xpath attributes</replaceable></term>
1025        <listitem>
1026         <para>
1027          Specifies indexing for record nodes given by
1028          <replaceable>xpath</replaceable>. Unlike directive
1029          elm, this directive allows you to index attribute
1030          contents. The <replaceable>xpath</replaceable> uses
1031          a syntax similar to XPath. The <replaceable>attributes</replaceable>
1032          have same syntax and meaning as directive elm, except that operator
1033          ! refers to the nodes selected by <replaceable>xpath</replaceable>.
1034          <!--
1035          xelm   /         !:w                 default index
1036          xelm   //        !:w                 additional index
1037          xelm   /gils/title/@att    myatt:w   index attribute @att in myatt
1038          xelm   title/@att          myatt:w   same meaning.
1039          -->
1040         </para>
1041        </listitem>
1042       </varlistentry>
1043       <varlistentry>
1044        <term>melm <replaceable>field$subfield</replaceable></term>
1045        <listitem>
1046         <para>
1047          This directive is specifically for MARC-formatted records,
1048          ingested either in the form of MARCXML documents, or in the
1049          ISO2709/Z39.2 format using the grs.marcxml input filter. You can
1050          specify indexing rules for any subfield, or you can leave off the
1051          <replaceable>$subfield</replaceable> part and specify default rules
1052          for all subfields of the given field (note: default rules should come
1053          after any subfield-specific rules in the configuration file).
1054         </para>
1055        </listitem>
1056       </varlistentry>
1057       <varlistentry>
1058        <term>encoding <replaceable>encodingname</replaceable></term>
1059        <listitem>
1060         <para>
1061          This directive specifies character encoding for external records.
1062          For records such as XML that specifies encoding within the
1063          file via a header this directive is ignored.
1064          If neither this directive is given, nor an encoding is set
1065          within external records, ISO-8859-1 encoding is assumed.
1066          </para>
1067        </listitem>
1068       </varlistentry>
1069       <varlistentry>
1070        <term>xpath <literal>enable</literal>/<literal>disable</literal></term>
1071        <listitem>
1072         <para>
1073          If this directive is followed by <literal>enable</literal>,
1074          then extra indexing is performed to allow for XPath-like queries.
1075          If this directive is not specified - equivalent to 
1076          <literal>disable</literal> - no extra XPath-indexing is performed.
1077         </para>
1078        </listitem>
1079       </varlistentry>
1080
1081       <!-- Adam's version 
1082       <varlistentry>
1083        <term>systag <replaceable>systemtag</replaceable> <replaceable>element</replaceable></term>
1084        <listitem>
1085         <para>
1086          This directive maps system information to an element during
1087          retrieval. This information is dynamically created. The
1088          following system tags are defined
1089          <variablelist>
1090           <varlistentry>
1091            <term>size</term>
1092            <listitem>
1093             <para>
1094              Size of record in bytes. By default this
1095              is mapped to element <literal>size</literal>.
1096             </para>
1097            </listitem>
1098           </varlistentry>
1099
1100           <varlistentry>
1101            <term>rank</term>
1102            <listitem>
1103             <para>
1104              Score/rank of record. By default this
1105              is mapped to element <literal>rank</literal>.
1106              If no score was calculated for the record (non-ranked
1107              searched) search this directive is ignored.
1108             </para>
1109            </listitem>
1110           </varlistentry>
1111           
1112           <varlistentry>
1113            <term>sysno</term>
1114            <listitem> 
1115             <para>
1116              Zebra's system number (record ID) for the
1117              record. By default this is mapped to element
1118              <literal>localControlNumber</literal>.
1119             </para>
1120            </listitem>
1121           </varlistentry>
1122          </variablelist>
1123          If you do not want a particular system tag to be applied,
1124          then set the resulting element to something undefined in the
1125          abs file (such as <literal>none</literal>).
1126         </para>
1127        </listitem>
1128       </varlistentry>
1129       -->
1130
1131       <!-- Mike's version -->
1132       <varlistentry>
1133        <term>
1134         systag
1135         <replaceable>systemTag</replaceable>
1136         <replaceable>actualTag</replaceable>
1137        </term>
1138        <listitem>
1139         <para>
1140          Specifies what information, if any, Zebra should
1141          automatically include in retrieval records for the 
1142          ``system fields'' that it supports.
1143          <replaceable>systemTag</replaceable> may
1144          be any of the following:
1145          <variablelist>
1146           <varlistentry>
1147            <term><literal>rank</literal></term>
1148            <listitem><para>
1149             An integer indicating the relevance-ranking score
1150             assigned to the record.
1151            </para></listitem>
1152           </varlistentry>
1153           <varlistentry>
1154            <term><literal>sysno</literal></term>
1155            <listitem><para>
1156             An automatically generated identifier for the record,
1157             unique within this database.  It is represented by the
1158             <literal>&lt;localControlNumber&gt;</literal> element in
1159             XML and the <literal>(1,14)</literal> tag in GRS-1.
1160            </para></listitem>
1161           </varlistentry>
1162           <varlistentry>
1163            <term><literal>size</literal></term>
1164            <listitem><para>
1165             The size, in bytes, of the retrieved record.
1166            </para></listitem>
1167           </varlistentry>
1168          </variablelist>
1169         </para>
1170         <para>
1171          The <replaceable>actualTag</replaceable> parameter may be
1172          <literal>none</literal> to indicate that the named element
1173          should be omitted from retrieval records.
1174         </para>
1175        </listitem>
1176       </varlistentry>
1177      </variablelist>
1178     </para>
1179     
1180     <note>
1181      <para>
1182       The mechanism for controlling indexing is not adequate for
1183       complex databases, and will probably be moved into a separate
1184       configuration table eventually.
1185      </para>
1186     </note>
1187     
1188     <para>
1189      The following is an excerpt from the abstract syntax file for the GILS
1190      profile.
1191     </para>
1192
1193     <para>
1194
1195      <screen>
1196       name gils
1197       reference GILS-schema
1198       attset gils.att
1199       tagset gils.tag
1200       varset var1.var
1201
1202       maptab gils-usmarc.map
1203
1204       # Element set names
1205
1206       esetname VARIANT gils-variant.est  # for WAIS-compliance
1207       esetname B gils-b.est
1208       esetname G gils-g.est
1209       esetname F @
1210
1211       elm (1,10)               rank                        -
1212       elm (1,12)               url                         -
1213       elm (1,14)               localControlNumber     Local-number
1214       elm (1,16)               dateOfLastModification Date/time-last-modified
1215       elm (2,1)                title                       w:!,p:!
1216       elm (4,1)                controlIdentifier      Identifier-standard
1217       elm (2,6)                abstract               Abstract
1218       elm (4,51)               purpose                     !
1219       elm (4,52)               originator                  - 
1220       elm (4,53)               accessConstraints           !
1221       elm (4,54)               useConstraints              !
1222       elm (4,70)               availability                -
1223       elm (4,70)/(4,90)        distributor                 -
1224       elm (4,70)/(4,90)/(2,7)  distributorName             !
1225       elm (4,70)/(4,90)/(2,10) distributorOrganization     !
1226       elm (4,70)/(4,90)/(4,2)  distributorStreetAddress    !
1227       elm (4,70)/(4,90)/(4,3)  distributorCity             !
1228      </screen>
1229
1230     </para>
1231
1232    </sect2>
1233
1234    <sect2 id="attset-files">
1235     <title>The Attribute Set (.att) Files</title>
1236
1237     <para>
1238      This file type describes the <replaceable>Use</replaceable> elements of
1239      an attribute set. 
1240      It contains the following directives. 
1241     </para>
1242     
1243     <para>
1244      <variablelist>
1245       <varlistentry>
1246        <term>name <replaceable>symbolic-name</replaceable></term>
1247        <listitem>
1248         <para>
1249          (m) This provides a shorthand name or
1250          description for the attribute set.
1251          Mostly useful for diagnostic purposes.
1252         </para>
1253        </listitem></varlistentry>
1254       <varlistentry>
1255        <term>reference <replaceable>OID-name</replaceable></term>
1256        <listitem>
1257         <para>
1258          (m) The reference name of the OID for
1259          the attribute set.
1260          The reference names can be found in the <replaceable>util</replaceable>
1261          module of <replaceable>YAZ</replaceable>.
1262         </para>
1263        </listitem></varlistentry>
1264       <varlistentry>
1265        <term>include <replaceable>filename</replaceable></term>
1266        <listitem>
1267         <para>
1268          (o,r) This directive is used to
1269          include another attribute set as a part of the current one. This is
1270          used when a new attribute set is defined as an extension to another
1271          set. For instance, many new attribute sets are defined as extensions
1272          to the <replaceable>bib-1</replaceable> set.
1273          This is an important feature of the retrieval
1274          system of Z39.50, as it ensures the highest possible level of
1275          interoperability, as those access points of your database which are
1276          derived from the external set (say, bib-1) can be used even by clients
1277          who are unaware of the new set.
1278         </para>
1279        </listitem></varlistentry>
1280       <varlistentry>
1281        <term>att
1282         <replaceable>att-value att-name [local-value]</replaceable></term>
1283        <listitem>
1284         <para>
1285          (o,r) This
1286          repeatable directive introduces a new attribute to the set. The
1287          attribute value is stored in the index (unless a
1288          <replaceable>local-value</replaceable> is
1289          given, in which case this is stored). The name is used to refer to the
1290          attribute from the <replaceable>abstract syntax</replaceable>. 
1291         </para>
1292        </listitem></varlistentry>
1293      </variablelist>
1294     </para>
1295
1296     <para>
1297      This is an excerpt from the GILS attribute set definition.
1298      Notice how the file describing the <emphasis>bib-1</emphasis>
1299      attribute set is referenced.
1300     </para>
1301
1302     <para>
1303
1304      <screen>
1305       name gils
1306       reference GILS-attset
1307       include bib1.att
1308
1309       att 2001          distributorName
1310       att 2002          indextermsControlled
1311       att 2003          purpose
1312       att 2004          accessConstraints
1313       att 2005          useConstraints
1314      </screen>
1315
1316     </para>
1317
1318    </sect2>
1319
1320    <sect2>
1321     <title>The Tag Set (.tag) Files</title>
1322
1323     <para>
1324      This file type defines the tagset of the profile, possibly by
1325      referencing other tag sets (most tag sets, for instance, will include
1326      tagsetG and tagsetM from the Z39.50 specification. The file may
1327      contain the following directives.
1328     </para>
1329
1330     <para>
1331      <variablelist>
1332
1333       <varlistentry>
1334        <term>name <emphasis>symbolic-name</emphasis></term>
1335        <listitem>
1336         <para>
1337          (m) This provides a shorthand name or
1338          description for the tag set. Mostly useful for diagnostic purposes.
1339         </para>
1340        </listitem></varlistentry>
1341       <varlistentry>
1342        <term>reference <emphasis>OID-name</emphasis></term>
1343        <listitem>
1344         <para>
1345          (o) The reference name of the OID for the tag set.
1346          The reference names can be found in the <emphasis>util</emphasis>
1347          module of <emphasis>YAZ</emphasis>.
1348          The directive is optional, since not all tag sets
1349          are registered outside of their schema.
1350         </para>
1351        </listitem></varlistentry>
1352       <varlistentry>
1353        <term>type <emphasis>integer</emphasis></term>
1354        <listitem>
1355         <para>
1356          (m) The type number of the tagset within the schema
1357          profile (note: this specification really should belong to the .abs
1358          file. This will be fixed in a future release).
1359         </para>
1360        </listitem></varlistentry>
1361       <varlistentry>
1362        <term>include <emphasis>filename</emphasis></term>
1363        <listitem>
1364         <para>
1365          (o,r) This directive is used
1366          to include the definitions of other tag sets into the current one.
1367         </para>
1368        </listitem></varlistentry>
1369       <varlistentry>
1370        <term>tag <emphasis>number names type</emphasis></term>
1371        <listitem>
1372         <para>
1373          (o,r) Introduces a new tag to the set.
1374          The <emphasis>number</emphasis> is the tag number as used
1375          in the protocol (there is currently no mechanism for
1376          specifying string tags at this point, but this would be quick
1377          work to add).
1378          The <emphasis>names</emphasis> parameter is a list of names
1379          by which the tag should be recognized in the input file format.
1380          The names should be separated by slashes (/).
1381          The <emphasis>type</emphasis> is the recommended data type of
1382          the tag.
1383          It should be one of the following:
1384
1385          <itemizedlist>
1386           <listitem>
1387            <para>
1388             structured
1389            </para>
1390           </listitem>
1391
1392           <listitem>
1393            <para>
1394             string
1395            </para>
1396           </listitem>
1397
1398           <listitem>
1399            <para>
1400             numeric
1401            </para>
1402           </listitem>
1403
1404           <listitem>
1405            <para>
1406             bool
1407            </para>
1408           </listitem>
1409
1410           <listitem>
1411            <para>
1412             oid
1413            </para>
1414           </listitem>
1415
1416           <listitem>
1417            <para>
1418             generalizedtime
1419            </para>
1420           </listitem>
1421
1422           <listitem>
1423            <para>
1424             intunit
1425            </para>
1426           </listitem>
1427
1428           <listitem>
1429            <para>
1430             int
1431            </para>
1432           </listitem>
1433
1434           <listitem>
1435            <para>
1436             octetstring
1437            </para>
1438           </listitem>
1439
1440           <listitem>
1441            <para>
1442             null
1443            </para>
1444           </listitem>
1445
1446          </itemizedlist>
1447
1448         </para>
1449        </listitem></varlistentry>
1450      </variablelist>
1451     </para>
1452
1453     <para>
1454      The following is an excerpt from the TagsetG definition file.
1455     </para>
1456
1457     <para>
1458      <screen>
1459       name tagsetg
1460       reference TagsetG
1461       type 2
1462
1463       tag       1       title           string
1464       tag       2       author          string
1465       tag       3       publicationPlace string
1466       tag       4       publicationDate string
1467       tag       5       documentId      string
1468       tag       6       abstract        string
1469       tag       7       name            string
1470       tag       8       date            generalizedtime
1471       tag       9       bodyOfDisplay   string
1472       tag       10      organization    string
1473      </screen>
1474     </para>
1475
1476    </sect2>
1477
1478    <sect2 id="variant-set">
1479     <title>The Variant Set (.var) Files</title>
1480
1481     <para>
1482      The variant set file is a straightforward representation of the
1483      variant set definitions associated with the protocol. At present, only
1484      the <emphasis>Variant-1</emphasis> set is known.
1485     </para>
1486
1487     <para>
1488      These are the directives allowed in the file.
1489     </para>
1490
1491     <para>
1492      <variablelist>
1493
1494       <varlistentry>
1495        <term>name <emphasis>symbolic-name</emphasis></term>
1496        <listitem>
1497         <para>
1498          (m) This provides a shorthand name or
1499          description for the variant set. Mostly useful for diagnostic purposes.
1500         </para>
1501        </listitem></varlistentry>
1502       <varlistentry>
1503        <term>reference <emphasis>OID-name</emphasis></term>
1504        <listitem>
1505         <para>
1506          (o) The reference name of the OID for
1507          the variant set, if one is required. The reference names can be found
1508          in the <emphasis>util</emphasis> module of <emphasis>YAZ</emphasis>.
1509         </para>
1510        </listitem></varlistentry>
1511       <varlistentry>
1512        <term>class <emphasis>integer class-name</emphasis></term>
1513        <listitem>
1514         <para>
1515          (m,r) Introduces a new
1516          class to the variant set.
1517         </para>
1518        </listitem></varlistentry>
1519       <varlistentry>
1520        <term>type <emphasis>integer type-name datatype</emphasis></term>
1521        <listitem>
1522         <para>
1523          (m,r) Addes a
1524          new type to the current class (the one introduced by the most recent
1525          <emphasis>class</emphasis> directive).
1526          The type names belong to the same name space as the one used
1527          in the tag set definition file.
1528         </para>
1529        </listitem></varlistentry>
1530      </variablelist>
1531     </para>
1532
1533     <para>
1534      The following is an excerpt from the file describing the variant set
1535      <emphasis>Variant-1</emphasis>.
1536     </para>
1537
1538     <para>
1539
1540      <screen>
1541       name variant-1
1542       reference Variant-1
1543
1544       class 1 variantId
1545
1546       type      1       variantId               octetstring
1547
1548       class 2 body
1549
1550       type      1       iana                    string
1551       type      2       z39.50                  string
1552       type      3       other                   string
1553      </screen>
1554
1555     </para>
1556
1557    </sect2>
1558
1559    <sect2>
1560     <title>The Element Set (.est) Files</title>
1561
1562     <para>
1563      The element set specification files describe a selection of a subset
1564      of the elements of a database record. The element selection mechanism
1565      is equivalent to the one supplied by the <emphasis>Espec-1</emphasis>
1566      syntax of the Z39.50 specification.
1567      In fact, the internal representation of an element set
1568      specification is identical to the <emphasis>Espec-1</emphasis> structure,
1569      and we'll refer you to the description of that structure for most of
1570      the detailed semantics of the directives below.
1571     </para>
1572
1573     <note>
1574      <para>
1575       Not all of the Espec-1 functionality has been implemented yet.
1576       The fields that are mentioned below all work as expected, unless
1577       otherwise is noted.
1578      </para>
1579     </note>
1580     
1581     <para>
1582      The directives available in the element set file are as follows:
1583     </para>
1584
1585     <para>
1586      <variablelist>
1587       <varlistentry>
1588        <term>defaultVariantSetId <emphasis>OID-name</emphasis></term>
1589        <listitem>
1590         <para>
1591          (o) If variants are used in
1592          the following, this should provide the name of the variantset used
1593          (it's not currently possible to specify a different set in the
1594          individual variant request). In almost all cases (certainly all
1595          profiles known to us), the name
1596          <literal>Variant-1</literal> should be given here.
1597         </para>
1598        </listitem></varlistentry>
1599       <varlistentry>
1600        <term>defaultVariantRequest <emphasis>variant-request</emphasis></term>
1601        <listitem>
1602         <para>
1603          (o) This directive
1604          provides a default variant request for
1605          use when the individual element requests (see below) do not contain a
1606          variant request. Variant requests consist of a blank-separated list of
1607          variant components. A variant compont is a comma-separated,
1608          parenthesized triple of variant class, type, and value (the two former
1609          values being represented as integers). The value can currently only be
1610          entered as a string (this will change to depend on the definition of
1611          the variant in question). The special value (@) is interpreted as a
1612          null value, however.
1613         </para>
1614        </listitem></varlistentry>
1615       <varlistentry>
1616        <term>simpleElement
1617         <emphasis>path ['variant' variant-request]</emphasis></term>
1618        <listitem>
1619         <para>
1620          (o,r) This corresponds to a simple element request
1621          in <emphasis>Espec-1</emphasis>.
1622          The path consists of a sequence of tag-selectors, where each of
1623          these can consist of either:
1624         </para>
1625
1626         <para>
1627          <itemizedlist>
1628           <listitem>
1629            <para>
1630             A simple tag, consisting of a comma-separated type-value pair in
1631             parenthesis, possibly followed by a colon (:) followed by an
1632             occurrences-specification (see below). The tag-value can be a number
1633             or a string. If the first character is an apostrophe ('), this
1634             forces the value to be interpreted as a string, even if it
1635             appears to be numerical.
1636            </para>
1637           </listitem>
1638
1639           <listitem>
1640            <para>
1641             A WildThing, represented as a question mark (?), possibly
1642             followed by a colon (:) followed by an occurrences
1643             specification (see below).
1644            </para>
1645           </listitem>
1646
1647           <listitem>
1648            <para>
1649             A WildPath, represented as an asterisk (*). Note that the last
1650             element of the path should not be a wildPath (wildpaths don't
1651             work in this version).
1652            </para>
1653           </listitem>
1654
1655          </itemizedlist>
1656
1657         </para>
1658
1659         <para>
1660          The occurrences-specification can be either the string
1661          <literal>all</literal>, the string <literal>last</literal>, or
1662          an explicit value-range. The value-range is represented as
1663          an integer (the starting point), possibly followed by a
1664          plus (+) and a second integer (the number of elements, default
1665          being one).
1666         </para>
1667
1668         <para>
1669          The variant-request has the same syntax as the defaultVariantRequest
1670          above. Note that it may sometimes be useful to give an empty variant
1671          request, simply to disable the default for a specific set of fields
1672          (we aren't certain if this is proper <emphasis>Espec-1</emphasis>,
1673          but it works in this implementation).
1674         </para>
1675        </listitem></varlistentry>
1676      </variablelist>
1677     </para>
1678
1679     <para>
1680      The following is an example of an element specification belonging to
1681      the GILS profile.
1682     </para>
1683
1684     <para>
1685
1686      <screen>
1687       simpleelement (1,10)
1688       simpleelement (1,12)
1689       simpleelement (2,1)
1690       simpleelement (1,14)
1691       simpleelement (4,1)
1692       simpleelement (4,52)
1693      </screen>
1694
1695     </para>
1696
1697    </sect2>
1698
1699    <sect2 id="schema-mapping">
1700     <title>The Schema Mapping (.map) Files</title>
1701
1702     <para>
1703      Sometimes, the client might want to receive a database record in
1704      a schema that differs from the native schema of the record. For
1705      instance, a client might only know how to process WAIS records, while
1706      the database record is represented in a more specific schema, such as
1707      GILS. In this module, a mapping of data to one of the MARC formats is
1708      also thought of as a schema mapping (mapping the elements of the
1709      record into fields consistent with the given MARC specification, prior
1710      to actually converting the data to the ISO2709). This use of the
1711      object identifier for USMARC as a schema identifier represents an
1712      overloading of the OID which might not be entirely proper. However,
1713      it represents the dual role of schema and record syntax which
1714      is assumed by the MARC family in Z39.50.
1715     </para>
1716
1717     <!--
1718      <emphasis>NOTE: FIXME! The schema-mapping functions are so far limited to a
1719       straightforward mapping of elements. This should be extended with
1720       mechanisms for conversions of the element contents, and conditional
1721       mappings of elements based on the record contents.</emphasis>
1722     -->
1723
1724     <para>
1725      These are the directives of the schema mapping file format:
1726     </para>
1727
1728     <para>
1729      <variablelist>
1730
1731       <varlistentry>
1732        <term>targetName <emphasis>name</emphasis></term>
1733        <listitem>
1734         <para>
1735          (m) A symbolic name for the target schema
1736          of the table. Useful mostly for diagnostic purposes.
1737         </para>
1738        </listitem></varlistentry>
1739       <varlistentry>
1740        <term>targetRef <emphasis>OID-name</emphasis></term>
1741        <listitem>
1742         <para>
1743          (m) An OID name for the target schema.
1744          This is used, for instance, by a server receiving a request to present
1745          a record in a different schema from the native one.
1746          The name, again, is found in the <emphasis>oid</emphasis>
1747          module of <emphasis>YAZ</emphasis>.
1748         </para>
1749        </listitem></varlistentry>
1750       <varlistentry>
1751        <term>map <emphasis>element-name target-path</emphasis></term>
1752        <listitem>
1753         <para>
1754          (o,r) Adds
1755          an element mapping rule to the table.
1756         </para>
1757        </listitem></varlistentry>
1758      </variablelist>
1759     </para>
1760
1761    </sect2>
1762
1763    <sect2>
1764     <title>The MARC (ISO2709) Representation (.mar) Files</title>
1765
1766     <para>
1767      This file provides rules for representing a record in the ISO2709
1768      format. The rules pertain mostly to the values of the constant-length
1769      header of the record.
1770     </para>
1771
1772     <!--
1773      NOTE: FIXME! This will be described better. We're in the process of
1774       re-evaluating and most likely changing the way that MARC records are
1775       handled by the system.</emphasis>
1776     -->
1777
1778    </sect2>
1779
1780    <sect2 id="field-structure-and-character-sets">
1781     <title>Field Structure and Character Sets
1782     </title>
1783
1784     <para>
1785      In order to provide a flexible approach to national character set
1786      handling, Zebra allows the administrator to configure the set up the
1787      system to handle any 8-bit character set &mdash; including sets that
1788      require multi-octet diacritics or other multi-octet characters. The
1789      definition of a character set includes a specification of the
1790      permissible values, their sort order (this affects the display in the
1791      SCAN function), and relationships between upper- and lowercase
1792      characters. Finally, the definition includes the specification of
1793      space characters for the set.
1794     </para>
1795
1796     <para>
1797      The operator can define different character sets for different fields,
1798      typical examples being standard text fields, numerical fields, and
1799      special-purpose fields such as WWW-style linkages (URx).
1800     </para>
1801
1802     <sect3 id="default-idx-file">
1803      <title>The default.idx file</title>
1804      <para>
1805       The field types, and hence character sets, are associated with data
1806       elements by the .abs files (see above).
1807       The file <literal>default.idx</literal>
1808       provides the association between field type codes (as used in the .abs
1809       files) and the character map files (with the .chr suffix). The format
1810       of the .idx file is as follows
1811      </para>
1812
1813      <para>
1814       <variablelist>
1815
1816        <varlistentry>
1817         <term>index <emphasis>field type code</emphasis></term>
1818         <listitem>
1819          <para>
1820           This directive introduces a new search index code.
1821           The argument is a one-character code to be used in the
1822           .abs files to select this particular index type. An index, roughly,
1823           corresponds to a particular structure attribute during search. Refer
1824           to <xref linkend="search"/>.
1825          </para>
1826         </listitem></varlistentry>
1827        <varlistentry>
1828         <term>sort <emphasis>field code type</emphasis></term>
1829         <listitem>
1830          <para>
1831           This directive introduces a 
1832           sort index. The argument is a one-character code to be used in the
1833           .abs fie to select this particular index type. The corresponding
1834           use attribute must be used in the sort request to refer to this
1835           particular sort index. The corresponding character map (see below)
1836           is used in the sort process.
1837          </para>
1838         </listitem></varlistentry>
1839        <varlistentry>
1840         <term>completeness <emphasis>boolean</emphasis></term>
1841         <listitem>
1842          <para>
1843           This directive enables or disables complete field indexing.
1844           The value of the <emphasis>boolean</emphasis> should be 0
1845           (disable) or 1. If completeness is enabled, the index entry will
1846           contain the complete contents of the field (up to a limit), with words
1847           (non-space characters) separated by single space characters
1848           (normalized to " " on display). When completeness is
1849           disabled, each word is indexed as a separate entry. Complete subfield
1850           indexing is most useful for fields which are typically browsed (eg.
1851           titles, authors, or subjects), or instances where a match on a
1852           complete subfield is essential (eg. exact title searching). For fields
1853           where completeness is disabled, the search engine will interpret a
1854           search containing space characters as a word proximity search.
1855          </para>
1856         </listitem></varlistentry>
1857        <varlistentry>
1858         <term>charmap <emphasis>filename</emphasis></term>
1859         <listitem>
1860          <para>
1861           This is the filename of the character
1862           map to be used for this index for field type.
1863          </para>
1864         </listitem></varlistentry>
1865       </variablelist>
1866      </para>
1867     </sect3>
1868
1869     <sect3 id="character-map-files">
1870      <title>The character map file format</title>
1871      <para>
1872       The contents of the character map files are structured as follows:
1873      </para>
1874
1875      <para>
1876       <variablelist>
1877
1878        <varlistentry>
1879         <term>lowercase <emphasis>value-set</emphasis></term>
1880         <listitem>
1881          <para>
1882           This directive introduces the basic value set of the field type.
1883           The format is an ordered list (without spaces) of the
1884           characters which may occur in "words" of the given type.
1885           The order of the entries in the list determines the
1886           sort order of the index. In addition to single characters, the
1887           following combinations are legal:
1888          </para>
1889
1890          <para>
1891
1892           <itemizedlist>
1893            <listitem>
1894             <para>
1895              Backslashes may be used to introduce three-digit octal, or
1896              two-digit hex representations of single characters
1897              (preceded by <literal>x</literal>).
1898              In addition, the combinations
1899              \\, \\r, \\n, \\t, \\s (space &mdash; remember that real
1900              space-characters may not occur in the value definition), and
1901              \\ are recognized, with their usual interpretation.
1902             </para>
1903            </listitem>
1904
1905            <listitem>
1906             <para>
1907              Curly braces {} may be used to enclose ranges of single
1908              characters (possibly using the escape convention described in the
1909              preceding point), eg. {a-z} to introduce the
1910              standard range of ASCII characters.
1911              Note that the interpretation of such a range depends on
1912              the concrete representation in your local, physical character set.
1913             </para>
1914            </listitem>
1915
1916            <listitem>
1917             <para>
1918              paranthesises () may be used to enclose multi-byte characters -
1919              eg. diacritics or special national combinations (eg. Spanish
1920              "ll"). When found in the input stream (or a search term),
1921              these characters are viewed and sorted as a single character, with a
1922              sorting value depending on the position of the group in the value
1923              statement.
1924             </para>
1925            </listitem>
1926
1927           </itemizedlist>
1928
1929          </para>
1930         </listitem></varlistentry>
1931        <varlistentry>
1932         <term>uppercase <emphasis>value-set</emphasis></term>
1933         <listitem>
1934          <para>
1935           This directive introduces the
1936           upper-case equivalencis to the value set (if any). The number and
1937           order of the entries in the list should be the same as in the
1938           <literal>lowercase</literal> directive.
1939          </para>
1940         </listitem></varlistentry>
1941        <varlistentry>
1942         <term>space <emphasis>value-set</emphasis></term>
1943         <listitem>
1944          <para>
1945           This directive introduces the character
1946           which separate words in the input stream. Depending on the
1947           completeness mode of the field in question, these characters either
1948           terminate an index entry, or delimit individual "words" in
1949           the input stream. The order of the elements is not significant &mdash;
1950           otherwise the representation is the same as for the
1951           <literal>uppercase</literal> and <literal>lowercase</literal>
1952           directives.
1953          </para>
1954         </listitem></varlistentry>
1955        <varlistentry>
1956         <term>map <emphasis>value-set</emphasis>
1957          <emphasis>target</emphasis></term>
1958         <listitem>
1959          <para>
1960           This directive introduces a
1961           mapping between each of the members of the value-set on the left to
1962           the character on the right. The character on the right must occur in
1963           the value set (the <literal>lowercase</literal> directive) of
1964           the character set, but
1965           it may be a paranthesis-enclosed multi-octet character. This directive
1966           may be used to map diacritics to their base characters, or to map
1967           HTML-style character-representations to their natural form, etc. The map directive
1968           can also be used to ignore leading articles in searching and/or sorting, and to perform
1969           other special transformations. See section <xref linkend="leading-articles"/>.
1970          </para>
1971         </listitem></varlistentry>
1972       </variablelist>
1973      </para>
1974     </sect3>
1975     <sect3 id="leading-articles">
1976      <title>Ignoring leading articles</title>
1977      <para>
1978       In addition to specifying sort orders, space (blank) handling, and upper/lowercase folding,
1979       you can also use the character map files to make Zebra ignore leading articles in sorting
1980       records, or when doing complete field searching.
1981      </para>
1982      <para>
1983       This is done using the <literal>map</literal> directive in the character map file. In a
1984       nutshell, what you do is map certain sequences of characters, when they occur <emphasis>
1985       in the beginning of a field</emphasis>, to a space. Assuming that the character "@" is
1986       defined as a space character in your file, you can do:
1987       <screen>
1988        map (^The\s) @
1989        map (^the\s) @
1990       </screen>
1991       The effect of these directives is to map either 'the' or 'The', followed by a space
1992       character, to a space. The hat ^ character denotes beginning-of-field only when
1993       complete-subfield indexing or sort indexing is taking place; otherwise, it is treated just
1994       as any other character.
1995      </para>
1996      <para>
1997       Because the <literal>default.idx</literal> file can be used to associate different
1998       character maps with different indexing types -- and you can create additional indexing
1999       types, should the need arise -- it is possible to specify that leading articles should be
2000       ignored either in sorting, in complete-field searching, or both.
2001      </para>
2002      <para>
2003       If you ignore certain prefixes in sorting, then these will be eliminated from the index,
2004       and sorting will take place as if they weren't there. However, if you set the system up
2005       to ignore certain prefixes in <emphasis>searching</emphasis>, then these are deleted both
2006       from the indexes and from query terms, when the client specifies complete-field
2007       searching. This has the effect that a search for 'the science journal' and 'science
2008       journal' would both produce the same results.
2009      </para>
2010     </sect3>
2011    </sect2>
2012   </sect1>
2013
2014   <sect1 id="formats">
2015    <title>Exchange Formats</title>
2016
2017    <para>
2018     Converting records from the internal structure to en exchange format
2019     is largely an automatic process. Currently, the following exchange
2020     formats are supported:
2021    </para>
2022
2023    <para>
2024     <itemizedlist>
2025      <listitem>
2026       <para>
2027        GRS-1. The internal representation is based on GRS-1/XML, so the
2028        conversion here is straightforward. The system will create
2029        applied variant and supported variant lists as required, if a record
2030        contains variant information.
2031       </para>
2032      </listitem>
2033
2034      <listitem>
2035       <para>
2036        XML. The internal representation is based on GRS-1/XML so
2037        the mapping is trivial. Note that XML schemas, preprocessing
2038        instructions and comments are not part of the internal representation
2039        and therefore will never be part of a generated XML record.
2040        Future versions of the Zebra will support that.
2041       </para>
2042      </listitem>
2043
2044      <listitem>
2045       <para>
2046        SUTRS. Again, the mapping is fairly straightforward. Indentation
2047        is used to show the hierarchical structure of the record. All
2048        "GRS" type records support both the GRS-1 and SUTRS
2049        representations.
2050        <!-- FIXME - What is SUTRS - should be expanded here -->
2051       </para>
2052      </listitem>
2053
2054      <listitem>
2055       <para>
2056        ISO2709-based formats (USMARC, etc.). Only records with a
2057        two-level structure (corresponding to fields and subfields) can be
2058        directly mapped to ISO2709. For records with a different structuring
2059        (eg., GILS), the representation in a structure like USMARC involves a
2060        schema-mapping (see <xref linkend="schema-mapping"/>), to an
2061        "implied" USMARC schema (implied,
2062        because there is no formal schema which specifies the use of the
2063        USMARC fields outside of ISO2709). The resultant, two-level record is
2064        then mapped directly from the internal representation to ISO2709. See
2065        the GILS schema definition files for a detailed example of this
2066        approach.
2067       </para>
2068      </listitem>
2069
2070      <listitem>
2071       <para>
2072        Explain. This representation is only available for records
2073        belonging to the Explain schema.
2074       </para>
2075      </listitem>
2076
2077      <listitem>
2078       <para>
2079        Summary. This ASN-1 based structure is only available for records
2080        belonging to the Summary schema - or schema which provide a mapping
2081        to this schema (see the description of the schema mapping facility
2082        above).
2083       </para>
2084      </listitem>
2085
2086      <listitem>
2087       <para>
2088        SOIF. Support for this syntax is experimental, and is currently
2089        keyed to a private Index Data OID (1.2.840.10003.5.1000.81.2). All
2090        abstract syntaxes can be mapped to the SOIF format, although nested
2091        elements are represented by concatenation of the tag names at each
2092        level.
2093        <!-- FIXME - Is this used anywhere ? -H -->
2094       </para>
2095      </listitem>
2096
2097     </itemizedlist>
2098    </para>
2099   </sect1>
2100
2101  </chapter>
2102  <!-- Keep this comment at the end of the file
2103  Local variables:
2104  mode: sgml
2105  sgml-omittag:t
2106  sgml-shorttag:t
2107  sgml-minimize-attributes:nil
2108  sgml-always-quote-attributes:t
2109  sgml-indent-step:1
2110  sgml-indent-data:t
2111  sgml-parent-document: "zebra.xml"
2112  sgml-local-catalogs: nil
2113  sgml-namecase-general:t
2114  End:
2115  -->