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