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